-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: adopt the on()
standard
#55
Comments
not that we conform too much to jQuery's API — but I do like the good parts. i can't even say i like |
On conformance: it helps people switch from jQuery and it also makes developing jQuery & Ender compatible plugins/modules so much easier (like exposing I'm not sure about the other major libraries but the fact that jQuery has gone the Prototype path makes is making it a bit of a standard. Of course Zepto also has the same API (minus |
What’s the current status/thoughts on this change? |
Going for it! when I have some breathing space anyway. The current plan is to take the newfixevent branch, merge the latest changes ( |
+1 |
Can use this too! |
Due for a 1.0 release, working code is in the 0.5-wip branch and you can try it out in an Ender build by installing bean@dev. Full details here: http://rod.vagg.org/2012/08/bean_v1/ |
all done, 1.0 is out with this change |
This is a request for comments on a bit of API breakage, I'd love to get feedback from Bean users on this, particularly if you use
on()
.on()
, as it currently exists in the Ender bridge, is incompatible with the standard set by Prototype and adopted by jQuery.I think the emerging
on()
standard is a good one and we should change Bean to conform to it. At least in the Ender bridge and perhaps in Bean proper. I suspect that since most jQuery users who are using Ender are probably usingbind()
or the other traditional jQuery style methods and since Bean'son()
is not directly compatible with jQuery's it may not be getting much use.Prototype's
on()
signature is:.on(element, eventName[, selector], handlerFn)
jQuery's
on()
signature is:.on(events [, selector] [, data], handlerFn)
Unfortunately, ours is (in Ender form):
.on([selector ,] events, handlerFn)
(note the order ofselector
andevents
)I propose that we change Bean to this signature:
.on(events [, selector], handlerFn)
with the possibility of adding the jQuerydata
parameter in the future (I imagine it would be quite helpful, but perhaps you should just curry your handler).This is a modified
integrate()
in the bridge that makes the change there:It's a bit long and I think I'd rather see
on()
added to Bean proper, perhaps even encouraged as the primary interface for adding. The signature there would look something like:.on(element, events [,selector], handlerFn [, selectorEngine])
.I'm not sure where this leaves
.off()
though, it's a funny API although it's consistent with having an.on()
I guess and we already have it in the bridge. Prototype doesn't bother withon()
, you still use.stopObserving()
.Incidentally, Prototype returns a special
handler
object that hasstart()
andstop()
methods that you can use to turn on and off the listener, so you don't really need anoff()
.The text was updated successfully, but these errors were encountered: