Best Practice For Storing Arbitrary Data In Widget . . .Data or Var?
When developing jQuery UI widgets how should one store arbritray data? I'm unclear on when I should use
data or when I should just use a
var declared in my _create. So if I am just storing values to use later which should I use?
For example what is the difference between using these in a _create function:
1
this.myVar = "foo"
2
e = this.element
e.data("myVar"
, "foo"
);
As I understand it 1 stores the data within the widget, and 2 is on the DOM element. But is there any actual difference in usage, when would I use one and not the other.