southman avatar

Declare an instance variable in jquery $widget.

south-man

Published: 05 Apr 2018 › Updated: 05 Apr 2018Declare an instance variable in jquery $widget.

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

Leave Declare an instance variable in jquery $widget. to:

Written by

Read more #jquery posts


Best Posts From southman

We have not curated any of south-man's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From southman