Extending $.fn.init Function
I'm trying to extend jQuery with the following: $.fn.extend({ initCore: $.fn.init, init: function (selector, context, rootjQuery) { return $.fn.initCore(sel
Solution 1:
$.fn.init
is the class constructor itself.
Try adding $.fn.init.prototype = $.fn
afterwords to restore the original prototype.
Solution 2:
I guess you're missing the context. Try
return $.fn.initCore.call(this, selector, context, rootjQuery);
or even easier
return this.initCore(selector, context, rootjQuery);
No, wait, init
is the constructor itself. That means
$.fn.initCore.call(this, selector, context, rootjQuery);
doSomeThingWith(this);
...
$.fn.init.prototype = $.fn;
or
var ob = new $.fn.initCore(selector, context, rootjQuery);
doSomeThingWith(ob);
return ob;
Post a Comment for "Extending $.fn.init Function"