プラグインのメソッド内にいくつかのローカル関数を配置していますが、外部からプラグインのメソッドの関数にアクセスできるかどうか疑問に思っています。
これは私のコードです、
$(document).ready(function(){
$.fn.hilight.init.plugins();
});
(function ($) {
var pluginName = 'hilight';
var methods = {
init: function(options){
var base = this;
// Method's function.
base.plugins = function() {
alert("an internal function");
}
var o = $.extend(true, {}, $.fn.hilight.defaults, options );
}
}
$.fn[pluginName] = 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 ); // always change 'init' to something else if you different method name.
} else {
$.error( 'Method ' + method + ' does not exist on jQuery.plugin' );
}
return this;
};
$.fn[pluginName].defaults = {
foreground: "red",
background: "yellow"
}
}( jQuery ));
もちろん、エラーが発生しますが、
TypeError: $.fn.hilight.init が定義されていません [このエラーで中断]
$.fn.hilight.init.plugins();
どうすればそれを達成できるのでしょうか?