I activate a jQuery script like this:
$('#an-id').drawbox();
This is the jQuery script (the important part):
(function($)
{
$.fn.extend(
{
drawbox: function()
{
// Default options
var defaults = {
caption: 'Caption',
// Canvas properties
lineWidth: 3,
lineCap: 'round',
lineJoin: 'round',
miterLimit: 10,
strokeStyle: 'green',
fillStyle: 'none',
shadowOffsetX: 0.0,
shadowOffsetY: 0.0,
shadowBlur: 0.0,
shadowColor: 'none',
}
options = $.extend(defaults);
return this.each(function()
{
//etc
The script runs fine, but I want to later get the 'options' value in a separate script. I'm guessing the options setting is set and stored in the function and can be retrieved later.
I've tried things like:
$('#an-id').drawbox.options
...but can't seem to get it.
options = $.extend(defaults);looks very wrong to me. I think you need "options" to be a parameter to the function, and then that line should look likeoptions = $.extend({}, defaults, options);As you've got it now, "options" is an implicit global (bad) and it'll be set to be a reference to the global jQuery object.