I am working on a groupdocs viewer, and want to re-create plug-in like that,
groupdocs code below
(function ($) {
var methods = {
init: function (options) {
debugger
var defaults = {
};
options = $.extend(defaults, options);
}
}
$.fn.viewer = function (method) {
console.log(method)
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method) {
return methods.init.apply(this, arguments);
} else {
$.error('Method' + method + ' does not exist on jQuery.viewer');
}
};
}(jQuery));
this code is working fine but when I create my custom code like below,
(function ($) {
var methods = {
init: function (options) {
debugger
var defaults = {
};
options = $.extend(defaults, options);
}
}
$.fn.secondFunction = function (method) {
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method) {
return methods.init.apply(this, arguments);
} else {
$.error('Method' + method + ' does not exist on jQuery.viewer');
}
};
}(jQuery));
secondFunction
and event init: is not executing,
what might be the problem with my code