Reputation: 384
I can't seem to figure out how to programmatically hide or show a setting.
I have tried this:
function onSwitchChange(prefName) {
var ms = require("sdk/simple-prefs").prefs.option1;
if(ms == "S"){
require("sdk/simple-prefs").prefs.option2.hidden = false;
}else{
require("sdk/simple-prefs").prefs.option2.hidden = true;
}
}
require("sdk/simple-prefs").on("option1", onSwitchChange);
Upvotes: 1
Views: 75
Reputation: 37238
you need to give your pref an oninputchanged
attribute.
see here: MDN :: Inline Options - Setting element changed notifications
it looks like you're using firefox-addon-sdk so after you make your addon to xpi. rename the xpi to zip then extract it. then edit options.xul then re-zip the files, then re-rename it to .xpi.
the edit you need to make to options.xul is find the setting
element of option2
. then add to it this:
<setting title="option1" type="string" pref="blahBlahBlah" oninputchanged="if (this.value == 'S') { document.querySelector('setting[title=\"option1\"]').style.display='none'; } else { document.querySelector('setting[title=\"option1\"]').style.display=''; } ">
option2
</setting>
Upvotes: 1