I defined my plugin base at http://docs.jquery.com/Plugins/Authoring
(function( $ ){
var methods = {
init : function( options ) { },
show : function( options ) { },
hide : function( ) { },
update : function( content ) {
this.show();
var arguments = { param: param };
var method = 'show';
methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
}
};
$.fn.tooltip = 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.tooltip' );
}
};
})( jQuery );
How to call show method inside update method?
EDIT
The method is showreferenced this. Using methods.show(options)or methods['show'](Array.prototype.slice.call( arguments, 1 ));works to call a method show, but the link to thisseems to be wrong because I got an error this.find(...) is not a function.
Method show:
show: function(options) {
alert("Options: " + options);
alert("Options Type: " + options.interactionType);
var typeCapitalized = capitalize(options.interactionType);
var errorList = this.find('#report' + typeCapitalized);
errorList.html('');
},
source
share