3

I have been using the jhtmlarea for a wysiwyg editor. Most of it is working. Though I can't figure out how to set the html inside of the textarea.
I have tried .html, .val, .attr('value',''), .text, though none of them work.

Any suggestions on how to do this/a better solution?

Thanks

Jess
  • 8,628
  • 6
  • 49
  • 67

3 Answers3

8

Set the original text area value and call updateHtmlArea:

$('#textAreaID').val(newHtml).htmlarea('updateHtmlArea');
Paul
  • 6,188
  • 1
  • 41
  • 63
3

This works for me

$("#yourTextArea").htmlarea('pasteHTML', "HTML to paste");

Hope it helps you and someone else :)

Mário Rodrigues
  • 833
  • 7
  • 21
  • Ended up using bbcode, but thanks a lot for this, will help in future projects – Jess Sep 28 '11 at 22:19
  • 1
    You can also do this: $("#jhtm").contents().find('body').html(data); If you change the JHtml script: - find line 41 (on the minified version) or search for "").height(textarea.height()); This will give you an ID to you iFrame object. Although it will only work with 1 iFrame but you can manage a workaround for sure! :) – Mário Rodrigues Sep 29 '11 at 11:42
-1

Not sure if this is what you're after but if you mean setting the text inside the jHtmlArea iFrame then you'll need to use the pasteHTML("text to insert"); method.

E.g.

$("#myTextAreaId").htmlarea ({ this.pasteHTML("Here's some programtically entered text."); })

harman_kardon
  • 1,567
  • 5
  • 32
  • 49
  • Almost there - inside the 'function click() { }' part you can simply start using the this keyword. i.e. this.pasteHTML("Here's some programtically entered text."); There's no need to re-fetch the element using jQuery ($("#myTextAreaId").htmlarea). – harman_kardon May 31 '11 at 08:10
  • This is what I have, tested in chrome, and Firefox, it doesn't work. Can you show me what I'm doing wrong? http://jsfiddle.net/aYYJe/3/ – Jess May 31 '11 at 21:22
  • The script won't save on the site? Not my fault! sorry – harman_kardon Aug 04 '11 at 16:10