Jump to content

Help retriving data from tinymce textarea


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 post
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 post
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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...