Closed mdfreeland closed 9 years ago
This setting is used to setup ea behavior and cannot be changed after event handlers are binded to form fields. Because of that, default setup should be changed just after ea script is loaded, e.g.:
<script src="expressive.annotations.validate.js"></script>
<script>
// turn off dependency validation
ea.settings.dependencyTriggers = undefined;
Nevertheless, I've just put small modification: https://github.com/JaroslawWaliszko/ExpressiveAnnotations/commit/3e2364984e1f8e7c7ea6e197718887a0e3f682a0, which uses namespaced events instead of plain ones.
Due to that, you can unbind selected delegated event handlers by their namespace from inside your script any time you want, leaving the other handlers untouched, e.g.:
// remove only change event handlers in the '.expressive.annotations' namespace
$('form').find('input, select, textarea').off('change.expressive.annotations');
// remove all event handlers in the '.expressive.annotations' namespace
// (analogy to setting dependencyTriggers to undefined)
$('form').find('input, select, textarea').off('.expressive.annotations');
In the next version (>= 2.6.1), I'm planning to extend functionality a bit, and handle issues like yours with the help of ea.settings.apply(options)
method.
This method will give an alternative way of settings
setup. It will be crucial to invoke for new set of dependency triggers to be re-bound, e.g.
ea.settings.apply({ dependencyTriggers: 'new set of events' });
alternatively, below construction will also work:
ea.settings.dependencyTriggers = 'new set of events';
ea.settings.apply();
The crucial thing is the invocation of apply()
. It's not yet published idea, if you have any suggestions do not hesitate to give it here.
This sounds like exactly the functionality I was hoping for. Looking forward to trying it out. Thanks!
Is it possible to change the settings exposed on the API from another script so that I don't have to modify the code in expressive.annotations.validate.js? Setting "ea.settings.dependencyTriggers = undefined;" in my own script changes the property value but does not change the behavior. As far as I can tell from the code, the dependencyTriggers events are bound to the controls at page load and not re-bound after settings are changed. Is there a way to trigger re-binding after changing the settings in my script?