我很难从插件本身调用公共方法。我不确定问题是什么。我究竟做错了什么?
(function($) {
var MyPlugin = function(){
/* PUBLIC */
this.publicFunction = function() {
// Do public things
};
/* PRIVATE */
var privateFunction = function() {
// Do private things
// Call this one public function
publicFunction(); // WANT THIS but doesn't work
}
};
$.fn.myPlugin = function() {
var myPlugin = new MyPlugin(options);
// Binding click to public function
$("a").bind('click', function(e){
e.preventDefault();
myPlugin.publicFunction($(this)); // AND WANT THIS but does
});
return myPlugin;
};
})(jQuery);