jQuery 1.7

jQuery 1.7 has been released. Most important change indefinitely is the introduction of the new .on() and .off() methods.

If you’ve been using .bind() and .delegate(), transitioning to these new functions should be no problem. If you’ve been using .live(), which you shouldn’t (also see this test on jsperf), then it’s a great moment to transition to the new syntax.

// bind -> on
$('a').bind('click', myHandler);
$('a').on('click', myHandler);
// bind, with extra params -> on
$('form').bind('submit', { val: 42 }, fn);
$('form').on('submit', { val: 42 }, fn);
// unbind -> off
// delegate -> on
$('.comment').delegate('a.add', 'click', addNew);
$('.comment').on('click', 'a.add', addNew);
// undelegate -> off
$('.dialog').undelegate('a', 'click.myDlg');
$('.dialog').off('click.myDlg', 'a');

// live -> on
$('a').live('click', fn);
$(document).on('click', 'a', fn);

// die -> off
$(document).off('click', 'a');

jQuery 1.7 Released →

jQuery Mobile Select: jQuery Mobile Navigation Replacement Plugin

A often-used practice in Responsive Web Design is to replace the menu/navigation (<ul>) with a dropdown (<select>) on small devices, this to prevent it from taking up the whole screen.

Today, my friend Jochen released a jQuery plugin that does the job for you automagically:

jQuery Mobile Select is a jQuery Plugin to replace the site navigation with a dropdown for mobile devices

Here’s before and after:

Bloggink: Mobile Navigation jQuery Plugin →
jQuery Mobile Select Source →

Demystifying jQuery 1.7′s $.Callbacks

$.Callbacks provides a way to manage lists of callbacks and it’s actually quite powerful. If we were to define two functions fn1 and fn2 we can then add these functions as callbacks to a $.Callbacks list and invoke them via the fire method. The result of this is that it becomes simple to construct complex lists of callbacks where input values can be passed through to as many functions as needed with ease.

Demystifying jQuery 1.7′s $.Callbacks →

jQuery Mobile: State of the Framework

At this fall’s jQuery Conference in Boston, MA, Filament Group’s Todd Parker and Scott Jehl presented the jQuery Mobile Framework keynote. The session covered the current state of the project, an overview of the releases since the first alpha last fall, direction for how best to make use of the framework today, and some upcoming tools

The info contained in the slides also forms a solid base to start developing from.

Slides from jQuery Mobile State of the Framework 2011, Todd Parker & Scott Jehl →