views:

2379

answers:

2

I'm having some problems with Jquery UI Dialog and TinyMCE.
Passing data to a text area works well with UI Dialog and Jquery.
So setting data in text area like this works fine:

        $("#MessageDialog #messageDto_Body").val(messagedata.Body);
        $("#MessageDialog").dialog("open");

When I attach a tinyMCE editor to the text area it correctly adds the editor (and without the UI window the content of the text area is preserved):

tinyMCE.execCommand('mceAddControl', false, 'messageDto.Body');

With UI Dialog the area is empty.

From what I have seen the tinyMCE works hiding the real text-area and adding a new one. I have also tried setting the content directly but no luck:

  tinyMCE.activeEditor.setContent(messagedata.Body, {format : 'bbcode'});

Any advice?

UPDATE: substituted Jquery UI Dialog with jqModal and everything works. I think the problem could rely not in TinyMce but in the Jquery UI Dialog

A: 

tinyMCE hides the textarea and adds multiple elements using the textarea's ID appended with '_' + element type. To access the contents of the iframe try something like this.

$("#content_ifr").contents().find("body").html(messagedata.Body);

Where #content is the ID of your textarea.

Shaun Humphries
+1  A: 

Perhaps the jQuery TinyMCE plugin will be helpful.

CmdrTallen