Javascript roaming settings using Win8

I am trying to use roaming settings in a WinJS application. The code I'm using is here:

var test = document.getElementById("testButton"); test.addEventListener("click", function () { var appData = Windows.Storage.ApplicationData.current; var roamingSettings = appData.roamingSettings; roamingSettings["test"] = "test"; var lbl = document.getElementById("testLabel"); lbl.innerHTML = roamingSettings["test"]; }); 

I didn't seem to have any problems with this in C #, but in WinJS I just get Undefined from reading.

+4
source share
2 answers

You need to use the values property of the roamingSettings object, which is an instance of ApplicationDataContainer .

+1
source

A few examples give the following results:

 var roamingSettings; roamingSettings["test"] = "test"; var lbl = document.getElementById("testLabel"); lbl.innerHTML = roamingSettings["test"]; 

undefined

 var roamingSettings["test"] = "test"; var lbl = document.getElementById("testLabel"); lbl.innerHTML = roamingSettings["test"]; 

undefined

 var roamingSettings = []; roamingSettings["test"] = "test"; var lbl = document.getElementById("testLabel"); lbl.innerHTML = roamingSettings["test"]; 

It worked. Here is jsFiddle . Look at what appData.roamingSettings is appData.roamingSettings and let me know if this will lead to a fix.

0
source

All Articles