Get tinymce input and alert() it
I am just building a form with multiple steps. On step 3, I have a tinymce editor. On step 4 I want to generate a preview of the input from tinymce. I have problems, to get the the contents form the tinymce input box. This is my current code开发者_如何学Go:
jQuery('#next_is_preview').click(function(){
alert(jQuery("#content_ifr").contents().find("#tinymce").html());
});
Currently it returns null. What could be the issue?
Probably safest to use the TinyMCE API to get the contents i.e.
alert(tinyMCE.activeEditor.getContent());
Does this work?
jQuery('#next_is_preview').click(function(){
alert(("#tinymce").html());
});
Use the API and your editors id (you used 'content')
alert(tinyMCE.get('content').getContent());
Your snippet is working for me! I used it to copy from a tinymce textarea to another one and your code did the trick perfectly:
$("#copyBtn").click(function(e){
e.preventDefault();
$("#spanish_ifr").contents().find("#tinymce").html($("#english_ifr").contents().find("#tinymce").html())));
});
精彩评论