Search code examples
jqueryrichtextrte

jQuery: Batiste Rich-Text Editor -- how to update content?


I'm using this lightweight jQuery plugin to create a rich-text editor:Batiste RTE jQuery Plugin

As part of a more complex form, I have the functionality of clearing changes and I want to be able to do this for the editor as well.

I keep the initial content in a variable, and I want to do something like: setContent(INITIAL_CONTENT), but I can't find a way to access the RTE object because $("textarea").rte(some-options-here) returns the textarea object rather than the rte object.

Any idea on how to make this happen?


Solution

  • I would just echo what Shaun said here, but I would also like to give an example of it in action. Note that one of the things that this example does is store off the INITIAL_CONTENT in a global variable because the RTE control replaces the textarea, not hides it, which I find a little unnerving.

    If you're concerned about it being in a global variable, you could probably store the initial contents off in some member of the DOM after it's created, but that's probably unnecessary for your purposes.

    The example of what you are trying to accomplish: http://jsbin.com/ixipu