locked
Saving WinJS.Binding.List data RRS feed

  • Question

  • I'm trying to save data that is stored in a WinJS.Binding.List object to the roaming storage folder by calling JSON.stringify on the list.  However, when I do this, I get the following runtime error:

    0x800a13aa - JavaScript runtime error: Circular reference in value argument not supported

    When I stringify the same exact data in a normal array instead of a WinJS.Binding.List, then it works just fine.  All of my data is stored in these WinJS lists though, so I don't know how to get this to save when for some reason the WinJS.Binding.List has a circular reference.

    Any help on how to store this data (with or without stringify if there is a better way) would be apprecitaed.

    Thursday, October 11, 2012 2:31 AM

Answers

All replies

  • Hi Steven.

    Take a look at this thread, it looks like a similar question.

    http://social.msdn.microsoft.com/Forums/en-US/winappswithhtml5/thread/c0ff5f49-f5c9-4c2d-93e2-ff679a6956fd

    But I think you can do something like JSON.stringify(yourList.slice(0)); to save your data.

    Joel

    Thursday, October 11, 2012 3:58 PM
  • Hi,

    I tried the above solution. But it works some time but when I add new item to the list it still complains with the same circular reference error.

    Please advise.

    Gokul

    Wednesday, May 15, 2013 1:36 PM
  • Hi,

    I tried the above solution. But it works some time but when I add new item to the list it still complains with the same circular reference error.

    Please advise.

    Gokul

    This is the function I wrote and it is working great.  The bindingList you pass in is a WinJS.Binding.List.  Then call .slice(0) on the resulting list, and finally JSON.stringify to put that array into a string for storage.  Hopefully that helps.

    unwrapList: function (bindingList) {
    var newList = [];
    for (var i = 0; i < bindingList.length; i++) {
    newList.push(WinJS.Binding.unwrap(bindingList.getAt(i)));
    }
    return newList;
    },

    Friday, May 17, 2013 1:51 AM