SetPreference does not always work?
I never had this problem before, but in my latest gadget it seems that setpreference does not always work! Has anyone else had this happen? Or know why! Thank you in advance
My code is straight forward so I don't know what I could be doing that would make it only work most of the time
function
updateinfo(){m_module.setPreference(
"feed", feedinput.value);m_module.setPreference(
"num", numinput.value);refreshContent();
[649 byte] By [
incendy] at [2008-2-15]
I, too, have had problems making multiple set calls in a row. I'm not sure if it's an asynchronous thing or what's going on. In my case, I was actually saving a
lot of data (looping through ~50-100 small items and saving each). I'd see odd randomness like the first two values would save, then I'd miss two or three, and then four more would get saved, and I'd lose the next one, and so on. In my case, I solved it by saving a single delimited string of my values rather than saving each value individually and then parsing that string when I retrieved it later via get. While that's probably overkill for two values, it's something you might look into if you consistently have this problem.
Shawn Clark - MSFT wrote: |
| Remember that on Spaces, anything you set with setPreference() will not immediately be available to getPreference(). The page must be refreshed/reloaded before your calls to getPreference will work. |
|
I've never really understood why that would be a problem. If you're able to save some information, that means you already have that available to you. Why would you try to re-load it with a getPreference() call? Call getPreference() during initialization to get any data that you may have previously saved, and then never call it again. There's simply no point. Manage your data within your gadget, call setPreference() to store it occasionally, and you're done.
Yes, I am aware Shawn and that is not the problem. What happens is I would say 1 out of 3 times SetPreference fails to save the value when there is more than one setPreference variable being set. No errors, just the value is not set