views:

268

answers:

1

I'm building a Dashboard Widget and I'm attempting to store preferences that persist across "sessions" (i.e., a user closing the widget and opening it again).

I've tried:

function setEmail(event)
{
var preferenceKey = "email";
var preferenceValue = $F("email");
widget.setPreferenceForKey(preferenceValue, preferenceKey);
}

function getEmail() {
var preferenceForKey = "email";
preferenceForKey = widget.preferenceForKey(preferenceForKey);
return preferenceForKey;
}

This works fine for the current session, but if the widget is closed and opened again, the data is lost.

Thanks!

+1  A: 

This seems to do the trick:

// Values you provide
var preferenceKey = "key";   // replace with the key for a preference
var preferenceValue = "value";  // replace with a preference to save

// Preference code
widget.setPreferenceForKey(preferenceValue, preferenceKey);
Ian Silber