How to set value dynamically in JHTMLarea

I am trying to set the value of a JHTML scope. But no luck. Can anybody help me. I have read so many articles, but I have not found anything about this. I also searched here and found one problem, but had no solution with it.

Any help would be appreciated.

Thank you and welcome

Zishan

+4
source share
5 answers

I have resolved this. Before calling the JHTMLArea method on textarea, first copy the value into the text box, and then apply the htmlarea function.

$("#txtNotes").val($('#hdnNotesDescription').val()); $("#txtNotes").htmlarea( { // Override/Specify the Toolbar buttons to show toolbar: ["bold", "italic", "underline", "link", "unlink", "orderedlist", "unorderedlist", "indent", "outdent", "justifyleft", "justifycenter", "justifyright"], toolbarText: $.extend({}, jHtmlArea.defaultOptions.toolbarText, { "bold": "Bold", "italic": "Italic", "underline": "Under Line", "link": "Hyperlink", "unlink": "Remove Hyperlink", "orderedlist": "Numbering", "unorderedlist": "Bullets", "indent": "Increase Indent", "outdent": "Decrease Indent", "justifyleft": "Align Text Left", "justifycenter": "Center", "justifyright": "Align Text Right" }), loaded:function(){ } }); 
+4
source

if you cannot use the "loaded" event, you can also try it as follows:

 $('textarea').htmlarea('pasteHTML','<h1>some <b>HTML</b> you want to add</h1>'); 

Paste text at current carriage position.

Good luck, Tamas

+1
source

This requires the right challenge. Use this.pasteHTML("Text to enter"); This will programmatically insert text into the editor.

eg.

 loaded:function(){ this.pasteHTML("Hello World"); } 
0
source

I struggled with this and found very few useful answers ... harman_kardon was close ... but in the end I had success:

 loaded:function(){ this.html(variable_containing_html); } 
0
source

I tried loading the html content with the click of a button using jQuery, I had a list of html content that could be loaded into jHhtmlArea in any order.

I tried using the idea from Tamas, but its code only added content to jHtmlArea, but I wanted the previous content to be deleted, so I tried this below -

 $('textarea').htmlarea('html','<h1>some <b>HTML</b> you want to add</h1>'); 

This removed the previous content and uploaded the new content.

Hope this helps someone.

0
source

All Articles