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.15
TRX 0.25
JST 0.037
BTC 94653.37
ETH 1794.69
USDT 1.00
SBD 0.88