What excites you the most about new versions of jQuery?

Recently released a new version of jQuery - jQuery v1.4. You can read all about it here . This allows you to do fairly neat things, such as:

$("div.test").bind({ click: function(){ $(this).addClass("active"); }, mouseenter: function(){ $(this).addClass("inside"); }, mouseleave: function(){ $(this).removeClass("inside"); } }); 

What do you like best about this new version? What made you go FINALLY?




Generosity added to get more feedback and accept response

+54
javascript jquery
Jan 15 '10 at 8:50
source share
15 answers

The best function, in my opinion, allows you to perform functions in setters:

 jQuery('li.selected').html(function(i, li) { return "<strong>" + li + "</strong>"; }); 

A lot of code requiring $ .each can now be removed.

+18
Jan 22 '10 at 5:16
source share
โ€” -

Believe it or not, the โ€œFINALLYโ€ moment for me was the addition of delay() :

 $("#notice").slideDown('500').delay(4000).slideUp('500'); // = Pure awesome :) 
+58
Jan 15 '10 at 8:53
source share

The ability to create elements on the fly more accurately, passing all the attributes as the second argument to jQuery() :

 jQuery('<div/>', { id: 'foo', mouseenter: function() { // do stuff }, html: jQuery('<a/>', { href: 'http://google.com', click: function() { // do stuff } }) }); 

All non-attribute properties are mapped to the corresponding jQuery method. That way, html will call .html() , and click will bind the new click event via .click() ...

+44
Jan 15 '10 at 10:50
source share

I really don't have a favorite, here is an overview of 15 new features for those who don't know what it is:

http://net.tutsplus.com/tutorials/javascript-ajax/jquery-1-4-released-the-15-new-features-you-must-know/

+18
Jan 15
source share

I'm a speed fanatic, so any speed improvement is always welcomed by me

+17
Jan 15
source share

For me it was like this:

"All events may be live events."

โ€œWe proudly found some additional activities among those supported by live (). 1.4 introduces cross-browser support for changes, submit, focusin, focusout, mouseenter, and mouseleave through event delegation in .live ().โ€

I have been waiting for this in an event of change for ages!

+12
Jan 15 '10 at 10:50
source share

Well, performance improvements are, of course, what I appreciate, but I think I canโ€™t say it โ€œfinallyโ€, because this is what is constantly improving :) The DOM-building syntax (Quick Element Construction) looks very convenient , and the detach method also looks quite applicable: it allows you to temporarily remove an object from the DOM, but retains all the handlers assigned to it, so that it will work exactly the same way when it is inserted again.

I assume that there is not much that was missing, but now that these new functions are there, there is a bunch that I really want to start using :)

+6
Jan 15 '10 at 9:02
source share

Event delegation for focus and bubble events:

+6
Jan 15 '10 at 9:33
source share

I really like to defer () and separate () the most, to be honest. Performance improvements are a huge plus, but delay () is probably the most amazing part of this. Simple but very useful. No more setTimeouts ().

+4
Jan 18 '10 at 23:49
source share

It was very modular with 1.3+. For example, when you do not need the ajax library, it is easy to create without it. Do not reduce file sizes.

+3
Jan 21 '10 at 23:25
source share

Call me crazy, but just the added amount of tests gives me a warm fuzzy feeling. I almost want to shift every answer :) _

+3
Jan 22 '10 at 12:51
source share

I think unwrap () is simple, elegant, and you will get innerHTML at the end!

A new method of unpacking the children of this parent and replacing said the parent with them. For example:

 <body> <div> <p>this</p> <p>is</p> <p>fun</p> </div> </body> $('div').unwrap(); <body> <p>this</p> <p>is</p> <p>fun</p> </body> 
+3
Jan 24
source share
 $.proxy() 

To make sure this always means this, not this ...

Example from here

 MyModule = function() { this.$div = $('#testdiv'); this.myString = "Hi! I'm an object property!"; this.$div.click($.proxy(this.handleClick, this)); }; MyModule.prototype.handleClick = function() { console.log(this.myString); // Hi! I'm an object property! }; var m = new MyModule(); 
+3
Jan 25 '10 at 5:37
source share

For me, this is an opportunity now to write event handlers using the live() handler. I know that live also present in the latest version (1.3.2), but it was not fully supported.

This makes the code infinitely simpler, especially if you have most of the DOM created on the fly or through Ajax requests.

More about live here: http://api.jquery.com/live/

+2
Jan 19 '10 at 7:37
source share

live () calls with events such as change are big for me. I want this for a long time.

+2
Jan 21
source share



All Articles