Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
@@ -756,10 +756,15 @@ if ( document.addEventListener ) { }); } jQuery.each(["bind", "one"], function( i, name ) { jQuery.fn[ name ] = function( type, data, fn ) { + // Redirect for live objects + if ( this.isLive && name === "bind" ) { + return this.live(type, data, fn); + } + // Handle object literals if ( typeof type === "object" ) { for ( var key in type ) { this[ name ](key, data, type[key], fn); } @@ -782,12 +787,32 @@ jQuery.each(["bind", "one"], function( i, name ) { jQuery.event.add( this, type, handler, data ); }); }; }); +function jQueryLive( selector , context ) { + jQuery.extend(this,{ + selector: selector, + context: context, + length: 0, + isLive: true + }); +} + +jQueryLive.prototype = jQuery.fn; + +jQuery.live = function( selector , context ) { + return new jQueryLive( selector , context ); +}; + jQuery.fn.extend({ unbind: function( type, fn ) { + // Redirect for live objects + if ( this.isLive ) { + return this.die(type, data, fn); + } + // Handle object literals if ( typeof type === "object" && !type.preventDefault ) { for ( var key in type ) { this.unbind(key, type[key]); } /* SAMPLE USAGE FOR RAUL IPISH */ $.live(".subElements","#parent").click(functor).hover(functorIn,functorOut);
This paste will be private.
From the Design Piracy series on my blog: