Keep plugin state in state manager (fixes #201)
Change-Id: If4a5305f3e41f1fcac4a47afeba613b3106c69fa
diff --git a/dev/js/src/state/manager.js b/dev/js/src/state/manager.js
index 339503d..136310b 100644
--- a/dev/js/src/state/manager.js
+++ b/dev/js/src/state/manager.js
@@ -33,9 +33,9 @@
// Parse a value and populate states
_parse : function (value) {
- if (value === undefined || value === '')
+ if (value == null || value == undefined || value == '')
return;
-
+
this._states = JSON.parse('{' + value + '}');
},
@@ -52,7 +52,7 @@
// Update the query component for states
_update : function () {
- this._e.value = this.toString();
+ this._e.setAttribute("value", this.toString());
},
@@ -63,6 +63,11 @@
const t = this;
let s = stateClass.create(values);
+ if (this._states[name] != undefined) {
+ if (values.includes(this._states[name]))
+ s.setIfNotYet(this._states[name]);
+ };
+
// Set default value
// TODO: It would be better to make this part
// of the state and serialize correctly using TOJSON()