Declare an instance variable in jquery $widget.

I developed a plugin using the $ widget factory provided by jquery. I used the widget variable as follows, and I created several instances, and the variable was replicated.

(function($) {
$.widget("custom.quadrantChart", {
_state : {
canvasSize : null,
......
}
......
});
}(jQuery));

So I tried Google search a million times and it was solved as follows. Hugh ~

(function($) {
$.widget("custom.quadrantChart", {
_create : function() {
this._canvasSize = null;
......
}
......
});
}(jQuery));

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now