Topic: How can I insert some data into Tinymce?
I get tinymce data with a get method:
ed=tinyMCE.get('myid');
ed.getContent
how can I insert some data into tinymce editor?
Pages 1
I get tinymce data with a get method:
ed=tinyMCE.get('myid');
ed.getContent
how can I insert some data into tinymce editor?
I get tinymce data with a get method:
ed=tinyMCE.get('myid');
ed.getContenthow can I insert some data into tinymce editor?
This inserts "Hello there" text at the cursor:
var ed = tinymce.activeEditor;
var text = 'Hello there';
ed.execCommand('mceInsertContent', false, text);This inserts "Hello there" (bolded HTML) at the cursor:
var ed = tinymce.activeEditor;
var html = '<p style="font-weight:bold;">Hello there</p>';
ed.execCommand('mceInsertContent', false, html);Hope this helps.
Thanks, but it doesnt work!!
Thanks, but it doesnt work!!
Strange. It should work. Try this:
setTimeout(function() {
alert(tinymce.activeEditor);
}, 5000);It should pop up after 5 seconds with the message "[object Object]". If it says "undefined", then you are doing something wrong either with the editor or else your Javascript isn't "reaching" the editor.
Let me know what you get and we can troubleshoot from there.
Thanks, but it doesnt work!!
Another thought... do you have the code written correctly? CASE is important. For example,
"tinymce.activeeditor" is wrong. It must be "tinymce.activeEditor".
Javascript is case sensitive.
Thank you so much, my problem solved. I have another question: How ca I clear all text inside the editor?
I have another question. does tinymce have a ruler like microsoft word?
Thank you so much, my problem solved. I have another question: How ca I clear all text inside the editor?
Use the "New Document" button or this code:
ed.execCommand('mceSetContent', false, '');(in fact, that is the code that the "newdocument" button uses!)
I have another question. does tinymce have a ruler like microsoft word?
As far as I know... the answer is "NO". I may be wrong though (someone chime in).
Pages 1
You are not logged in. Please login or register.