You can store private data on the instance itself, for example, inside the _create
, you should be able to do this.instanceVar = "huzzah!"
$.widget("ui.myPlugin", {
options: {
foo: "foo"
},
_create: function() {
this.instanceVar = "huzzah!"
},
_setOption: function() {
this.instanceVar = "worky!";
},
destroy: function() {
console.log(this.instanceVar);
}
});
$(document).myPlugin().myPlugin("option","foo","bar").myPlugin("destroy"); // "worky"
$("body").myPlugin().myPlugin("destroy"); // "huzzah!