Я работаю в средстве просмотра groupdocs и хочу воссоздать плагин следующим образом:
code groupdocs ниже
(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));
этот код работает нормально, но когда я создаю мой пользовательский код, как показано ниже,
(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
и событие init: не выполняется,
в чем может быть проблема с моим кодом