Hello!
I'm trying to use javascript to append text in rich text editor fields.
It works as expected in Description field with
AJS.$("#description").val(AJS.$("#description").val() + " new *formatted* text");
But the same trick doesn't work in Comment field.
Nothing happens if you call:
AJS.$("#comment").val(AJS.$("#comment").val() + " new *formatted* text")
Although, if you run AJS.$("#comment").val(), then console returns expected value. But it does not appear on screen and it's not being added as a comment if submitted.
By fiddling around in console, I found that this way it almost works:
AJS.$("textarea#comment.textarea.long-field.wiki-textfield.mentionable.wiki-editor-initialised").val(AJS.$("textarea#comment.textarea.long-field.wiki-textfield.mentionable.wiki-editor-initialised").val() + " new *formatted* text");
Added text appears in Comment field.
But if you change anything manually in comment field and run command once again, all manually applied changes are being deleted and the script just adds scripted text to "previous" state of the field.
Has anybody encountered this problem?
Is there any other way to adjust text in Comment field on browser side?
Figured it out.
Even more specific reference works:
AJS.$("textarea#comment.textarea.long-field.wiki-textfield.mentionable.wiki-editor-initialised.wiki-edit-wrapped.richeditor-cover").val(AJS.$("textarea#comment.textarea.long-field.wiki-textfield.mentionable.wiki-editor-initialised.wiki-edit-wrapped.richeditor-cover").val() + " new *formatted* text");
Earning the Mindful Member badge proves you know how to lead with kindness, plus it enters you into a giveaway for exclusive Atlassian swag. Take the quiz, grab the badge, and comment on our announcement article to spread the good vibes!
Start here
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.