Archive

Archive for the ‘Code’ Category

JQuery Plugin Mechanism

May 11, 2011 Leave a comment

Extending the Library

Another excellent article on extending JQuery.

The jQuery library is centered on a root object, which exposes a number of methods. After doing whatever tasks it was called to do, each method just returns the instance of its parent object. In this way, a new call to another method can be arranged on the same expression.

(function( $ ){
 $.fn.yourPluginName = function() {
 // your code here
 };
})(jQuery)

Read the rest of the article http://drdobbs.com/web-development/229403172

Advertisements
Categories: Code, JQuery

JQuery Event Handling

December 18, 2010 Leave a comment

De-complicating Browser Event Handling

JQuery simplifies event handling across browsers.

In jQuery, you define an event handler by simply passing the code you want to execute to a function that identifies the particular event.  There are several ready-made functions for most common events such as click, blur, hover, change, dblclick, focus, select (text selection), ready, scroll, and resize , plus multiple events for keyboard and mouse actions.

Read the article at Dr. Dobbs http://www.drdobbs.com/java/228800832

Categories: Code, JQuery

jLambda : Don’t call us, we’ll call us

November 1, 2009 Leave a comment

Very cool article on lisp-ing JQuery — I’m really loving this.

jLambda: A jQuery plugin for succinct anonymous functions | from.bz.

… from the article

Generally, the plugin adds the global function $l (lowercase L, for “lambda”), which “wraps up” a jQuery expression into a function that can be executed later. For example, instead of writing:

1.function() {
2.$(this).hide().addClass('foo').css('color', '#fff')..;
3.}

The plugin allows you to write:

1.$l.hide().addClass('foo').css('color', '#fff')..;

This allows succinct expression of callback functions.

1.// Without plugin:
2.$('.foo').click(
3.function() {
4.$(this).hide();
5.});
6.
7.// With plugin:
8.$('.foo').click($l.hide());
Categories: Code, JQuery