function showPreview(value) { $("#preview-container"). load("/material-preview. php", {s:value}); } $('thetextarea'). live("keyup",function (e) { var material = this.
The TinyMCE getContent and setContent methods You can do this using the getContent() API method. Let's say you have initialized the editor on a textarea with id=”myTextarea”. This will return the content in the editor marked up as HTML.
You don't need to use tinymce as a jQuery plugin but the option is there if you would like to. The vast majority of the tinymce source code is in the tinymce. min. js file and the jQuery.
Call
tinyMCE.triggerSave();
after that you'll be able to use jquery selector
$("#yourtextareaID").val();
tinyMCE.get('yourTextAreaId').getContent();
See the following link on how to define the onKeyUp event to work with TinyMCE:
http://www.tinymce.com/wiki.php/API3:event.tinymce.Editor.onKeyUp
Essentially when you initialize tinyMCE you define your onKeyUp event handler. I think a regular selector won't work here since the text is inside a separate iFrame. The TinyMCE API lists a method .getContent()
that may work. ie. Something like this:
tinyMCE.init({
setup : function(ed) {
ed.onKeyUp.add(function(ed, e) {
//showPreview ( $('.mceContentBody').val() );
showPreview (tinyMCE.activeEditor.getContent({format : 'raw'}) );
});
}
});
Also see: http://www.tinymce.com/wiki.php/API3:method.tinymce.Editor.getContent
Your problem is more with TinyMCE than jQuery or Javascript specifically. If the above doesn't work you'll need to read the TinyMCE docs and/or API to figure out how to do what you want to achieve.
You can use this too.
tinyMCE.activeEditor.getContent();
TinyMCE provides a jQuery pluggin that you can use in conjunction with the onKeyUp command in the API
$('textarea.tinymce').tinymce({
// Location of TinyMCE script
script_url : 'path/to/tiny_mce.js',
theme : "simple",
setup : function(ed) {
ed.onKeyUp.add(function(ed, l) {
console.debug('Key up event: ' + e.keyCode);
});
}
});
There is also a preview plugin, which I suspect does what you were after more directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With