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");
Join us to learn how your team can stay fully engaged in meetings without worrying about writing everything down. Dive into Loom's newest feature, Loom AI for meetings, which automatically takes notes and tracks action items.
Register today!Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.