Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Script to add info rich text editor fields and comment

Alex Trebek
Contributor
February 14, 2023 edited

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?

1 answer

1 accepted

1 vote
Answer accepted
Alex Trebek
Contributor
February 14, 2023

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");

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian community, loom ai, atlassian loom ai, loom, atlassian ai, record recaps of meetings, meeting recaps, loom recaps, share meeting recaps,

Loom’s guide to great meetings 📹

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!
AUG Leaders

Atlassian Community Events