Open oliverbock opened 8 years ago
This document originally discussed the legacy syntax with the initizialize
method. Looks like commit 071f718 removed this discussion when syntax was changed to use factory
. See the example in Develop > Introduction for how to initialize instance data with the new syntax.
To access the instance data later, use the HTMLWidgets.getInstance
method to retrieve a mutable object.
// If you don't already have el, paste a selector
let el=$("#htmlwidget-f1d67d7048e9d46ef168").get(0);
HTMLWidgets.getInstance(el)
>>> {s: "sigma", renderValue: ƒ, resize: ƒ}
HTMLWidgets.getInstance(el).s="theta";
HTMLWidgets.getInstance(el)
>>> {s: "theta", renderValue: ƒ, resize: ƒ}
This is evidently the same as accessing a property of the element:
el["htmlwidget_data_init_result"]
In the Develop > Advanced Topics document, it includes a bukket point in Overview that says
But I can find no section that describes this. I am looking for a mechanism to store the state of an htmlwidget between uses. Is that what this is referring to? Where can I find more information?