plugin callback parameter not working
HTML
<a id="switchTest" href="#">switch</a>
JavaScript
(function ($) {
$.fn.switcherButton = function (options) {
// Set the default options
var settings = $.extend({},$.fn.switcherButton.defaults, options);
this.click(function () {
$.fn.switcherButton.switched = !$.fn.switcherButton.switched;
settings.onSwitch.call($.fn.switcherButton.switched);
});
return this;
};
// Plugin defaults – added as a property on our plugin function.
$.fn.switcherButton.defaults = {
onSwitch: function() {}
};
$.fn.switcherButton.switched = false;
}(jQuery));
$("#switchTest").switcherButton({
onSwitch: function(switched){
if(typeof switched === "undefined")
alert("callback param = undefined");
else
if(switched)
alert("callback param = true");
else
alert("callback param = false");
}
});