Re:Differences Between jQuery .bind() vs .live() vs .delegat...
by jonknee on Monday February 06, 2012 @10:35AM
(#3557713)
> Maybe there should be a jQuery version with no legacy code.
They're deprecating stuff, so it's just a matter of time. I think that's the sensible way to do things.
http://blog.jquery.com/2011/11/08/building-a-slimmer-jquery/
They're also taking steps to be able and use Google Closure Compiler's advanced optimizations, which would let you build jQuery against your code and trim out everything that's not used. Pretty handy.
Re:Differences Between jQuery .bind() vs .live() vs .delegat...
by nfriedly on Monday February 06, 2012 @04:21PM
(#3559234)
> They're also taking steps to be able and use Google Closure Compiler's advanced optimizations...
That is awesome, thanks for pointing it out!
Re:Differences Between jQuery .bind() vs .live() vs .delegat...
by emehrkay on Monday February 06, 2012 @10:32AM
(#3557698)
The overall api is strange. The each loops are backwards from the spec (key, value) instead of (value, key) and there are instances where it is key, value in jquery, there are instances where method names just don't make sense (I'd expect something like size to be dimensions etc), getters and setters as the same method, way too much argument overloading, inconsistent approach (selector.action, but wrap is the opposite of how the rest of the lib works). There is no kind of inheritance for their plugin architecture.
These are just things off the top of my head. I feel like jQuery is the same as PHP when it comes to api, and I make a living doing PHP.
Re:Differences Between jQuery .bind() vs .live() vs .delegat...
by mark_story on Monday February 06, 2012 @12:44PM
(#3558333)
jQuery.map() jQuery.each() having their arguments has caused me more than a few WAT moments.
One way I solve the issue around overloaded apis is by not using them. I just pretend .click() and friends just don't exist.
Re:Differences Between jQuery .bind() vs .live() vs .delegat...
by davej on Monday February 06, 2012 @10:23AM
(#3557671)
Yep, the best advice for a newcomer is to just use `.on()` and familiarise yourself with that API. You can ignore the other event handler methods because they're all just shortcuts or legacy methods.
Re:Differences Between jQuery .bind() vs .live() vs .delegat...
by emehrkay on Monday February 06, 2012 @10:35AM
(#3557710)
I like MooTools. When they added event delegation to their library, they simply modified the existing addEvent method to parse the event name instead of adding new method after new method -- seems like a more thought out approach.
$(selector').addEvent('click:relay(selector)', fn)
Re:Differences Between jQuery .bind() vs .live() vs .delegat...
by dmethvin on Monday February 06, 2012 @10:32AM
(#3557691)
Exactly. It would simplify the documentation to simply deprecate everything but .on() but would that justify breaking all the existing code out there? Not to me. The old APIs need to stay around so that code continues to work.
Re:Differences Between jQuery .bind() vs .live() vs .delegat...
by cgoddard on Tuesday February 07, 2012 @01:43PM
(#3563130)
Even if they excised the old methods from the code, hopefully no one is linking to jQuery trunk or something as their primary library. The old versions would still be around. Just some simple work might have to be done to update a web app to using the latest versions of jQuery.
Re:Differences Between jQuery .bind() vs .live() vs .delegat...
by cgoddard on Tuesday February 07, 2012 @01:40PM
(#3563111)
They could deprecate the old methods and still keep them around as long as makes sense. There's no rule that deprecated methods have to be gotten rid of during the next major revision or anything.
Millions (if not hundred of millions) of websites rely on jQuery, switching to a newer version that breaks old code will wreak havoc and make these sites unusable.
But this shouldn't stop jQuery from improving. If you have read the article from the beginning, you'll see how the jQuery team was improving the binding functionality. It has a cost, certainly. Maybe there should be a jQuery version with no legacy code.