sleemanj / xinha

WYSIWYG HTML Editor Component (turns <textarea> into HTML editors)
http://trac.xinha.org/
Other
13 stars 2 forks source link

Setting editor.config.Events after makeEditors has no effect (Trac #1602) #1602

Closed sleemanj closed 3 years ago

sleemanj commented 11 years ago

The example configuration script in source:trunk/examples/XinhaConfig.js describes that you can adjust an editor's configuration values between calls to makeEditors() and startEditors():

      xinha_editors   = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);

      /** STEP 5 ***************************************************************
       * If you want to change the configuration variables of any of the
       * editors,  this is the place to do that, for example you might want to
       * change the width and height of one of the editors, like this...
       *
       *   xinha_editors.myTextArea.config.width  = '640px';
       *   xinha_editors.myTextArea.config.height = '480px';
       *
       ************************************************************************/

      /** STEP 6 ***************************************************************
       * Finally we "start" the editors, this turns the textareas into
       * Xinha editors.
       ************************************************************************/

      Xinha.startEditors(xinha_editors);

This mostly works; however, I've noticed that if you try to set the config.Events object at this stage, like so, it has no effect:

xinha_editors   = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);
xinha_editors.myTextArea.config.Events = {'onBeforeSubmit': function() { alert("foo"); };
Xinha.startEditors(xinha_editors);

On the other hand, updating sub-objects of the existing config.Events object does work properly:

xinha_editors   = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);
xinha_editors.myTextArea.config.Events.onBeforeSubmit = function() { alert("foo"); };
Xinha.startEditors(xinha_editors);

This should probably be documented; and possibly fixed, or an explanatory error/warning triggered.

Reported by ejucovy, migrated from http://trac.xinha.org/ticket/1602

sleemanj commented 11 years ago

1339 Fixed