Detect changes in Wysiwyg textares/iframe inside form

Events happening in the community are now at Drupal community events on www.drupal.org.
miro_dietiker's picture

I'm trying to check forms for changes. In IRC #jquery the idea came up to use serialize() a form on .ready and compare serialize() it at a certain point to detect changes...

As soon as a wysiwyg editor (fckeditor in our case) is present, changes won't be tracked in that field. It shows that editor content is no more part of the form DOM.

I'm strongly looking for documentation about how to talk to wysiwyg api to check for changes in the editor. I didn't find the correct way to identify the wysiwyg editor instance, given the form element.

How would you suggest to identify the instance and check for changes in that case?

Thanks for your help.

Comments

You can get the Wysiwyg

twod's picture

You can get the Wysiwyg editor instance from Drupal.wysiwyg.instances. It's keyed by the original textarea id.
However, there is currently no way to get the contents from the editor using the API. One of the tasks for Wysiwyg 3.x is to complete this API and add some kind of 'getContent' method. There will most likely also be a method for syncing the editor contents back to the original field without having to detach and re-attach the editor (which is currently your only cross-editor option, and will be extremely annoying for your users).

You could implement a native plugin for each editor, or otherwise listen to the events they fire when the content changes. In the event handlers it should be easy to sync the current content back to the original textarea and maybe trigger one of those change checks.

Wysiwyg

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: