4

I have been struggling to set the value of JHTML Area. But no luck. Can anyone please help me out. I have read so many articles but i didn't find anything regarding it. I have also searched here and found one problem but have no solution with it.

Any help would be appreciated.

Thanks and regards,

Zeeshan

Zeeshan
  • 91
  • 2
  • 6

6 Answers6

4

I have resolved it. Before calling the JHTMLArea method on textarea copy the value in the textarea first 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(){                            
                    }
                });  
Zeeshan
  • 91
  • 2
  • 6
1

if you cannot use the 'loaded' event, you can also try it this way:

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

This will insert the text at current caret position.

Good luck, Tamas

Tamas
  • 326
  • 4
  • 9
0

I was struggling with this and finding very few helpful answers... harman_kardon was close... but ultimately I had success with:

loaded:function(){
    this.html(variable_containing_html);                            
}
Tony Carbone
  • 484
  • 4
  • 10
0

I was trying to load the html content on the click of a button using jQuery, I had the list of html content which could be loaded in jHhtmlArea in any order.

Tried using the idea from Tamas, but his code only appended content to the jHtmlArea but I wanted the previous content to be removed so I tried this below-

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

This removed the previous content and loaded the new content.

Hope it helps someone.

Manik Arora
  • 4,702
  • 1
  • 25
  • 48
0

For anyone struggling with getting this to work when <textarea id="testnotes" runat="server"></textarea>

Try txtNotes.InnerHtml = "<h1>some <b>HTML</b> you want to add</h1>";

Andrew
  • 59
  • 5
0

There's a proper call to do this. Use this.pasteHTML("Text to enter"); This will programmatically insert text into the editor.

e.g.

loaded:function(){
        this.pasteHTML("Hello World");                            
    }
harman_kardon
  • 1,567
  • 5
  • 32
  • 49
  • I have used it but was not giving proper result. Thats why i have used it in that way and thats get the job done. – Zeeshan Jun 03 '11 at 04:10