This is jQuery code to create a custom plugin.
(function( $ ){
var methods = {
get_me_now: 'abc',
init : function( options ) { // how to access get_me_now in here? },
show : function( ) { // IS },
hide : function( ) { // GOOD },
update : function( content ) { // !!! }
};
$.fn.tooltip = function( method ) {
// Method calling logic
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 );
I have a variable ‘get_me_now’. I call it like this: $(‘#test’).tooltip(‘init’);
How does the ‘init’ function get the ‘get_me_now’ variable?
You can just reference methods.