I had created two general purpose jquery plugins files. 'script1.js' and 'script2.js'
Some project need 'script1.js' & other need 'script2.js'. My new project need these two plugins.
How can i use these plugin with same namespace.
My namespace is 'abc'
script1.js
----------
(function($)
{
$.fn.abc = function ()
{
return
{
foo1: function()
{
console.log("foo1");
},
foo2: function()
{
console.log("foo2");
}
}
};
})(jQuery);
$(".element").abc().foo1(); //working fine - 'foo1'
script2.js
----------
(function($)
{
$.fn.abc = function ()
{
return
{
foo3: function()
{
console.log("foo3");
}
}
};
})(jQuery);
Can i extend the first plugin with the second plugin.
$(".element").abc().foo3(); //expected print 'foo3'
$(".element").abc().foo1(); //expected print 'foo1'
foo1 & foo2 is need almost every application. but foo3 is not needed every application. foo3 is a larger plugin.