It would be nice to be able to listen for when items in the form builder are opened or closed. Currently, it is very difficult to accomplish similar things by binding to various click
events due to the fact that many operations in form_builder.js
return false;
, which effective stops event propagation.
For example, when trying to integrate a WYSIWYG editor with the webform markup component, I was getting a JS error when editing the component because the WYSIWYG instance was not properly unset when the form builder item was closed.
This patch adds the following events that other scripts can bind to. All events pass the active element as an additional argument, if there is one:
formBuilder.setActive
formBuilder.closeActive
formBuilder.unsetActive
Comment | File | Size | Author |
---|---|---|---|
#3 | form_builder-javascript-events-1992196-3.patch | 1.61 KB | svax |
form_builder-js_events.patch | 1.42 KB | theunraveler |
Comments
Comment #1
quicksketchThanks for the patch. Events would definitely be a good idea. The only question I think we should consider is where the event should be attached. Perhaps we could put it on the Form Builder wrapper, rather than the whole document? Document-wide events often seem a bit overkill, and may cause issues when you have multiple instances of something on a page (not that would be a problem with Form Builder I hope).
Comment #2
torotil CreditAttribution: torotil commentedI also think the element of the event should be narrowed down at least to the form_builder wrapper.
This is a bad thing in itself. So if think this should be addressed too.
return false
should be replaced withevent.preventDefault()
and only if it's really needed also withevent.stopPropagation()
.Comment #3
svax CreditAttribution: svax commentedI updated the patch with the events attached to '.form-builder-wrapper'.
Comment #4
torotil CreditAttribution: torotil commentedThanks for changing the element for the events. I still would reduce the occurences of
return false;
too. Maybe this could even substitute the explicit events.