$.fn.extend extends $.fn if you pass only one parameter. It's useful if you're adding more methods (plugins) but if you just want to add a single plugin it's the same as $.fn.tablesorterPager = function(){ ... }
Accordingly $.extend extends $, which is the same as $.tablesorterPager=function(){ ... } On Nov 7, 3:40 am, George <[EMAIL PROTECTED]> 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.