JQuery allows to bind a handler to a few events at once, please, see http://api.jquery.com/bind/ "Multiple Events".
I think the support can be added for binding multiple events to the Ample API similar to JQuery functionality.
For example, the following should bind handlers both to the "focus" and "blur" events:
ample.bind("focus blur", function (event) {
...
});
ample.query(cssSelector).bind("focus blur", function (event) {
...
});
While I understand that it is not a goal to include complicated custom APIs into Ample SDK but rather make existing ones work well and be extensible, still this addition may be a nice syntactic sugar. Also the described behavior is something that I would personally expect from the API.
Also I would expect for "ample.bind()" to return "ample" and not "undefined" so that we can chain invocations together like with "ample.query(cssSelector).bind()".
The only concern that I have is backward compatibility: the old code may be broken with this API update if it used events with blanks in the event name. But using event names with blanks in them would be very strange to begin with.
JQuery allows to bind a handler to a few events at once, please, see http://api.jquery.com/bind/ "Multiple Events".
I think the support can be added for binding multiple events to the Ample API similar to JQuery functionality.
For example, the following should bind handlers both to the "focus" and "blur" events:
While I understand that it is not a goal to include complicated custom APIs into Ample SDK but rather make existing ones work well and be extensible, still this addition may be a nice syntactic sugar. Also the described behavior is something that I would personally expect from the API.
Also I would expect for "ample.bind()" to return "ample" and not "undefined" so that we can chain invocations together like with "ample.query(cssSelector).bind()".
The only concern that I have is backward compatibility: the old code may be broken with this API update if it used events with blanks in the event name. But using event names with blanks in them would be very strange to begin with.