I'm trying to reset tinymce content.
On the beginning there is some 'A content'. User changed it to some 'B content', but he don't want to save it, so he can click 'cancel' button and whole content is back to 'A' version.
A content is text saved earlier, so it's not constant. How to reset tinyMce text to original one? Html:
<div id="someDiv">Content A</div>
Would be nice to see something like this. If content was modified, cancel button will reset content to original:
if($('#someDiv').tinymce().isDirty()) {:
$('#someDiv').tinymce().reset();
}
I'm trying to reset tinymce content.
On the beginning there is some 'A content'. User changed it to some 'B content', but he don't want to save it, so he can click 'cancel' button and whole content is back to 'A' version.
A content is text saved earlier, so it's not constant. How to reset tinyMce text to original one? Html:
<div id="someDiv">Content A</div>
Would be nice to see something like this. If content was modified, cancel button will reset content to original:
if($('#someDiv').tinymce().isDirty()) {:
$('#someDiv').tinymce().reset();
}
This can be easily done.
You need to add this (using the setup parameter) to your configuration:
tinyMCE.init({
...
setup : function(ed) {
ed.onInit.add(function(ed, evt) {
ed.init_content = ed.getContent();
});
}
});
on buttonclick you call the following to reset the editor content
var ed = tinymce.get('your_editor_id');
ed.setContent(ed.init_content);
EDIT - For tinymce 4.x the syntax for attaching editor events has changed and is now:
tinymce.init({
...
setup: function (ed) {
ed.on('init', function () {
...
});
}
});