Hi Everyone -

There's been some rabble-rousing concerning the destructive nature of
jQuery (it's ok, rousing is a good thing ;-)). I claimed that it'd be
easy to have it exist as a plugin. Well, it took me all of 10 minutes,
but here it is:

jQuery.fn._pushStack = jQuery.fn.pushStack;
                
jQuery.fn.pushStack = function(){
    var ret = jQuery.fn._pushStack.apply( jQuery(this), arguments );
    ret.prevObject = this;
    return ret;
};
                
jQuery.fn.end = function(){
    return this.prevObject || jQuery([]);
};

You can see a demo (requires Firebug) here:
http://john.jquery.com/jquery/test/destruct.html

So, if the destructive nature of jQuery bothers you - and you can't
wait for jQuery 2.0, then just stick the above code in the header of
your site (after jQuery) and you'll be good to go. Enjoy!

--John

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to