I'm writing a plugin for an accordion, that auto rotates. I am trying to add a callback that will fire each time a new slide is presented and if the user has set it in the options on init. So, for example:
Callback set in the options:
var defaults =
{
callback: function(arg) {}
};
var options = $.extend(defaults, options);
Rotation script:
function autorotation() {
var arg = 'hi';
options.callback.call(this);
}
Init plugin script:
$('element').myplugin({
callback: function(arg) {
alert(arg);
}
});
My question is, how do I write this correctly so that I can successfully pass the argument each time the slides rotate to the client outside of the plugin? I hope this make sense to everyone. I tried to be as simple as possible.