[development] Drupal way of doing onchange
hovercrafter at earthlink.net
Sun Nov 22 23:14:43 UTC 2009
Unless it is added inline with a defer then you do risk loading problems:
Without the defer, edit-cc-funciton will be undefined.
Even though this scenario is most likely for private use, something else
that should be considered in contrib modules as well as core (and
possibly added to the JS coding standards) is the use of event
namespaces. That way you can easily disable any bound events later on in
the code without having to rewrite the original JS. Something like:
Now if I want to unbind that function all I got to do is:
Want to unbind every event that module binds to?
It really adds a nice new layer of extensibility.
Scott Reynen wrote:
> On Nov 22, 2009, at 2:25 PM, Greg Holsclaw wrote:
> > the
> > event handlings later, but that is a completely different topic.
> I'll bite. One might argue that inline JS violates Drupal coding
> That could be read with a more narrow meaning (i.e. event function
> bindings are okay, nothing else), but is there any actual benefit to
> doing inline JS? It's not as if it's more difficult to select an
> element and apply an event handler in jQuery.
> Doing things the "purist" (right) way seems to be both easier and
> better for modularity, so why not do it?
> Scott Reynen
More information about the development