Rob Kelly
Rob Kelly

Reputation: 31

How do i get the value from a tinyMCE textbox using jquery?

I am trying to get a the value of a textbox that is using tinyMCE (jQuery Version) but when i do i get no content from the textbox. See my code below;

var content = $( "#content_textarea" ).val();
alert(content);

Also i am not using a form and the code is activated using a button.

I have also tried this code;

var content = tinyMCE.get('content_textarea').getContent();
alert(content);

What am i doing wrong?

Upvotes: 2

Views: 6670

Answers (4)

Gordan Knežević
Gordan Knežević

Reputation: 41

Try:

var editor='content_textarea';
var content =tinyMCE.activeEditor.getContent();
alert(content);

Or if you don't like that, you can do:

tinyMCE.triggerSave();
var content =$('#content_textarea').val();
alert(content);

Both work for me.

Upvotes: 4

HammerNL
HammerNL

Reputation: 1841

Just do:

tinymce.get("original textarea id").getContent()

Upvotes: 1

Dave L.
Dave L.

Reputation: 9781

Based on the documentation here:

http://www.tinymce.com/wiki.php/jQuery_Plugin

You should use:

// Gets the contents from a specific editor
alert($('#someeditor').html());

Upvotes: 0

Jurudocs
Jurudocs

Reputation: 9165

ive had the same problem with ckeditor... mybe this is of interest.

CKEDITOR.instances['editor1'].getData();

helped me out....whereby editor1 is the name of the instance

Upvotes: -1

Related Questions