I'm trying following code to create a plugin. I'm getting error at the line if(options.controls == true)
The error I get is 'options is not defined'.
How should I define it?
(function($) {
$.fn.jwslider = function(options){
var defaults = {
controls: true
};
var options = $.extend(defaults, options);
}
init();
function init()
{
if(options.controls == true)
{
alert("controls true");
}
}
}(jQuery));
optionsis defined only inside the$.fn.jwsliderscope, you have to declare it outside and then assign it inside that function(you will need to give a new name to the parameter of the function, maybeopts)