It merges the new function into jQuery, meaning you can then apply all of the library's methods to it. Try http://docs.jquery.com/Plugins/Authoring if you haven't yet seen it.
I often write tiny add-ons in basic style, eg function menutoggle () { do stuff }; But these only serve one purpose; they can't be 'plugged into' other jQuery routines. Steven Holzner's book on OOP has a section on extending; try http://tinyurl.com/6nv5hh Cherry. George wrote: > Hi guys, I need some help with understanding JQuery/Javacript. > I am far away form being a Javascript guru so I am not sure I > understand why something done this (or other) way. > > I am looking at tablesorterPager plug-in and it's written following > way > > (function($) { > $.extend({ > tablesorterPager: new function() { > .......blablabla...... > } > }); > // extend plugin scope > $.fn.extend({ > tablesorterPager: $.tablesorterPager.construct > }); > > })(jQuery); > > > If I were to write this plug in I would do it like this > (function($) > { > $.fn.tablesorterPager = function() > { > .....blabblabla.... > } > })(jQuery); > > > Questions: > Any advantages of writing it the way it's written? > Basically what is this $.extend({....}) for....? What does it achive. > > Thanks > George.