Declare an instance variable in jquery $widget.

in #jquery7 years ago (edited)

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));

Coin Marketplace

STEEM 0.17
TRX 0.24
JST 0.034
BTC 96170.07
ETH 2806.40
SBD 0.67