que define mi base plugin en http://docs.jquery.com/Plugins/AuthoringjQuery plugin de llamada a la función pública dentro de otra función pública
(function($){
var methods = {
init : function(options) { },
show : function(options) { },
hide : function() { },
update : function(content) {
// How to call the show method inside the update method
// I tried these but it does not work
// Error: not a function
this.show();
var arguments = { param: param };
var method = 'show';
// Error: options is undefined
methods[ method ].apply(this, Array.prototype.slice.call(arguments, 1));
}
};
$.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);
Cómo llamar al método Show en el interior del método de actualización?
EDITAR:
El método show
hace referencia a this
. El uso de methods.show(options)
o methods['show'](Array.prototype.slice.call(arguments, 1));
funciona para llamar al método show
pero luego la referencia a this
parece estar equivocada porque recibí un error this.find(...) is not a function
.
El método 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('');
},
'methods.show()' 'obras pero no $ (this) .show()' – Sydney
Ok, no estaba tan seguro de '$ (this) .show();'. –
He editado la pregunta porque ahora tengo un problema dentro del método 'show' debido a una referencia a' this' – Sydney