Dear All,
Can anyone advise how we can store a simple gadget preference either
locally within a cookie or any other means?
Below is a simple attempt to do this which currently fails. We can see how
and where gadgets pass data to server and it seems the environment
javascripts always use default data for saving even if there is
user-entered data available. It might be a misconfiguration of these
javascripts but I cannot be sure.
Can anyone explain a method of storing a simple gadget preference locally
within a cookie? I'm imagining there must be an example of this somewhere.
Isn't that the purpose of cookiebaseduserprefstore.js?
<Module>
<ModulePrefs title="User preferences test" height="200">
<Require feature="setprefs"/>
</ModulePrefs>
<UserPref name="string" display_name="Enter string"
default_value="Default"/>
<Content view="preview, home, canvas">
<![CDATA[
<h1 id="h1">__UP_string__</h1>
<script>
var prefs = new gadgets.Prefs();
function init() {
document.getElementById('h1').innerHTML = prefs.getString('string');
}
gadgets.util.registerOnLoadHandler(init);
</script>
]]>
</Content>
</Module>
Kind regards,
Darren