[jQuery] jQuery API discussion
Hi folks,
I'd like to discuss the jQuery API in general and the current event API
in detail:
The main problem is the ambiguity of events, unevents and DOM methods.
Some examples:
$().unload() - Removes load event handlers AND triggers unload event
$().submit() - Triggers the submit event, but doesn't actually submit
anything, that is, it does not (try to) call the submit method of the
matched elements. $().blur() and $().focus() have are very similar.
$().load(Function) - Binds a handler to the load event
$().load(String, Hash, Function) - Starts an AJAX request
The ambiguity could be avoided by forcing the user to use bind(),
unbind() and trigger(). A reliable solution, but not very sexy.
This is also a general problem of the jQuery API. There are more then
200 API methods, all bound to a single "class". Hell on earth for OO
fanatics, but handy if you know what you are doing.
If we go back to the roots and stick to bind(), unbind(), trigger(),
attr() and css(), we could remove all those events and html and css
attribute shortcut methods, greatly reducing the number of methods. By
adding those methods, or rather only parts of it, like click(), back via
plugins, the jQuery meat could be reduced to some extend, maybe even
reducing the barrier for newcomers by simplifying the API docs.
bind(), unbind(), trigger() and attr() could be improved to a hash as
css() alread does, allowing you to set several attributes at once or
adding/removing several events with one method call. Passing a hash
without values to attr could be quite sexy, too, when it simply fills
the hash with all available values.
Your ideas and opinions, please!
For all newcomers: I'd like to hear about your first impression of the
jQuery API! This is invaluable for all those geeks who spent way too
much time with jQuery.
Regards
JörnjQuer
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/