i have method addobject on jquery prototype have done using jquery.fn.extend().
jquery.fn.extend({ addobject : function(objectkey){ this[objectkey] = {}; } }); now want add method addnewobject prototype. trying emulate below scenario
function addobject(){ ... } addobject.prototype.addnewobject = function(){ ... } how addobject accessible new keyword?
instead of using extend use:
// insulate plugin in iife (function() { // declare function function addobject(options) { return this.each(function(){}); } // add prototypes addobject.prototype.addnewobject = function() {} // extend plugin passing function reference $.fn.addobject = addobject; })(jquery); see https://jqueryboilerplate.com/ lots of information, guides , patterns etc developing plugins
Comments
Post a Comment