Advanced HTML Editor 3 Support Product Page

Answered

Workaround for AdvHTMLEdit and Ajax submit

Asked 17 Sep 2011 13:11:03
1
has this question
17 Sep 2011 13:11:03 David Smith posted:
This isn't really a bug, but a workaround. If you use jQuery to process forms containing the Advanced HTML Editor via Ajax submits, then you may find that the HTML editor field ignores any changes made to it's content. This is presumably because the extension hooks into the Submit event to copy the contents of the behind-the-scenes iFrame that is used to hold the edited field contents back to the textarea that is actually submitted, and this event may not be fired, or may be reassigned to another handler depending on how you submit the form (this is particularly an issue if you use Malsup's jQuery Form plugin).
The solution is to manually update the textarea field prior to submitting the form. This can be accomplished by the following line of javascript (assumming your HTML field is call 'advHTMLEdit1'):

$('#advHTMLEdit1').val($('iframe').contents().find('body').html());

Hope this is of some use to people.[8D]

Official Answer

Replied 19 Sep 2011 11:32:20
It is true that the editor binds to the submit event and then updates the textarea, but it does a bit more then only copy the html, it does several cleanup etc also.

The correct way is the following:
$('#advHTMLEdit1').data('dmxEditor').save();


The data('dmxEditor') will give you access to the editor class and the save() method will fill the textarea with the content (with all cleanup functions called).

Replies

Replied 19 Sep 2011 11:32:20
19 Sep 2011 11:32:20 Patrick Woldberg replied:
It is true that the editor binds to the submit event and then updates the textarea, but it does a bit more then only copy the html, it does several cleanup etc also.

The correct way is the following:
$('#advHTMLEdit1').data('dmxEditor').save();


The data('dmxEditor') will give you access to the editor class and the save() method will fill the textarea with the content (with all cleanup functions called).

Reply to this topic