Jump to content

Help retriving data from tinymce textarea


DIY-Forum

Recommended Posts

Hello everyone I have now worked on this trying several options for hours, I have tried tinyMCE.get('.content').getContent(); and regular jquery $('.content').val(); but it still won't work for me.

I like the new look of the simple version of tinyMCE so I hope I won't have to give it up just yet!

 

I'm retriving it for saving as: var content = $('.content').val();

 

I tried to retrive the data from the iframe that tinyMCE makes itself, but that would not work either.. But I might have done it wrong. Hope someone can help me out! :)

 

Kris

Link to comment
Share on other sites

Hello,

 

Try this, it works for me:

var content = tinyMCE.activeEditor.getContent({format : 'html'});

Also, make sure you have tinymce.init set/initiated for the textarea, should come before the above in the javascript code. Something like:

tinymce.init({selector: "#myTextArea",theme: "modern",plugins: [         "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",         "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",         "save table contextmenu directionality emoticons template paste textcolor"         ],toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | print preview media fullpage | forecolor backcolor emoticons" });
  • Like 1
Link to comment
Share on other sites

 

Hello,

 

Try this, it works for me:

var content = tinyMCE.activeEditor.getContent({format : 'html'});

 

Hello Sir!

 

Thank you very much, works like a charm! :)

 

I am currently only having one editor on the page, but I notice the "activeEditor" line, does that mean I cannot use more than one?

 

Thanks again,

Kris

Link to comment
Share on other sites

Check out this: http://fiddle.tinymce.com/e5caab/40

 

You should be able to have many editors on a page and able to get their content using tinyMCE.get('textarea selector here').getContent(); like it's shown in the Fiddle I edited.

 

Click the Get content button that is below the 2 tinyMCE textareas. It should display via alert the content for each tinyMCE textarea.

 

Also to note, in the fiddle, the inits are using editor_selector: instead of just selector: With editor_selector, it appears you can select via class name. In order to select via id, it appears you have to use selector: as shown in this fiddle I edited: http://fiddle.tinymce.com/e5caab/41

Edited by Don E
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...