by mark_ndg on Tue Jan 27, 2009 9:56 pm
I have been in the process of migrating a CMS from TinyMCE to WYMeditor, and I encountered a couple of issues I would like to get some input on.
The first issue is that there seems to be- in my particular case, anyway- some irregularity in the calling of wymeditor.update() when the form is submitted. I have an instance of WYMeditor on the page, and the form submit button is given the default updateSelector class of "wymupdate", and the default updateEvent of "click". Frequently, however, the update() method will not be called prior to the form being submitted, and thus any changes to the text field are not saved to the database. Browsing the forums and various other sites, it appears to me to be an issue with the 'click' event itself, and that 'mousedown' seems to be the preferred updateEvent, as it seems to fire a few milliseconds sooner than 'click'. ('mousedown' fires immediately upon pressing the mouse button, while 'click' does not fire until the button is released, so that is likely the reason for the difference)
The second issue I encountered was that there are pages in the CMS that require multiple instances of WYMeditor in the same form. When the form is submitted (regardless of whether the aforementioned updateEvent is changed), only one of the WYMeditor instances will have its update() method called. Which particular instance seems to be determined randomly. My suspicion is that there is some sort of conflict occurring when multiple WYMeditor instances attempt to bind their own update() method to a single submit button's 'click'/'mousedown' event, and that the multiple editors are essentially "fighting for supremacy". My experience with jQuery is quite limited, so my attempts to debug this have been meagre at best.
All the documentation I have been able to find regarding multiple WYMeditor instances on a single page seem to place each instance in its own form, with each editor bound to its own form's submit button. Is there any documentation regarding multiple instances in a single form? Should some be created if there is not? Searching the forms found various users with similar issues, but none that I could find the same as mine.
I was able to kill both of these birds with a single stone, by creating a custom function bound to my form submit button's 'mousedown' event, which iterates through WYMeditor.INSTANCES and explicitly calls the update() method for each, however that is not quite as graceful as being able to define everything in a single configuration.
I am curious as to whether this as been documented as an official bug (or whether it is indeed a bug at all, or rather some flaw in my implementation that I haven't caught on to yet). I didn't find anything in the trac, but I'm not entirely sure what I would even be looking for.
I am using the latest release as of this posting, 0.5b2.
I would appreciate any input that could be provided. If this has indeed been answered somewhere else, please point me in the right direction.