简体   繁体   English

持久仪表板小部件首选项

[英]Persistent Dashboard Widget Preferences

I'm building a Dashboard Widget and I'm attempting to store preferences that persist across "sessions" (ie, 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! 谢谢!

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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM