--- nicedit.js.o Fri Feb 25 01:08:00 2011 +++ nicedit.js Fri Apr 22 13:36:47 2011 @@ -4,11 +4,31 @@ * Attach this editor to a target element. */ Drupal.wysiwyg.editor.attach.nicedit = function(context, params, settings) { + // Intercept submit handlers so we can unbind them later. + var oldAddEvent = bkLib.addEvent, + submitHandlers = []; + bkLib.addEvent = function(obj, type, fn) { + if (type == 'submit') { + submitHandlers.push({ + 'obj' : obj, + 'fn' : fn + }); + } + oldAddEvent(obj, type, fn); + } // Attach editor. var editor = new nicEditor(settings); editor.panelInstance(params.field); editor.addEvent('focus', function () { Drupal.wysiwyg.activeId = params.field; + }); + // Restore the helper function and register our unbinder. + bkLib.addEvent = oldAddEvent; + editor.addEvent('remove', function () { + var handlerInfo; + while (handlerInfo = submitHandlers.pop()) { + (handlerInfo.obj.removeEventListener ? handlerInfo.obj.removeEventListener('submit', handlerInfo.fn, false) : handlerInfo.obj.detachEvent('onsubmit', handlerInfo.fn)); + } }); };