I am working on a jQuery plugin and I would like for the user to pass in a method name to be executed after a flag (in the code) is set to true. I already have the flags working as needed, I just need a way to execute the method that is passed. For example:
(function(jQuery){
$.fn.extend({
pluginName: function(options) {
var defaults = {
parameter1: 0,
method: function(){}
}
var options = $.extend(defaults, options);
return this.each(function() {
var opt = options;
var flag = false;
if(opt.parameter1 > 0){
flag = true;
}
if(flag){
//call users method
}
jQuery(this).hide();
});//END return
}//END counter method
});//END extend
})//END function
//Return jQuery object
(jQuery);
The user would call it like this:
$("#divName").pluginName({
parameter1: 1,
method: function(){alert("test");}
});
I haven't tested the code above, it's just an illustration so you can see what I'm trying to accomplish. Thanks in advanced!