我正在尝试使用 optionselectorHTML5 教程-app。但似乎无法获取所选选项(索引或其他)。我还想将索引设置为预定义选项。
这是我的html:
<div class="settingGroup">
<p>Video Transcoding:</p>
<section data-role="option-selector" id="transcodingOptions">
<ul>
<li data-value="0">
<p>no transcoding</p>
</li>
<li data-value="1">
<p>simple transcoding</p>
</li>
<li data-value="2">
<p>full transcoding</p>
</li>
</ul>
</section>
</div>
和 JS:
UI.optionselector("transcodingOptions", false);
// always the same index:
console.debug(UI.optionselector("transcodingOptions").selectedIndex);
// seems to get the right data-value (fires three times):
UI.optionselector("transcodingOptions").onClicked(function(e) {
console.debug(e.values);
// save:
localStorage.setItem("transcoding", e.values);
});
// set selectedIndex --> not working:
UI.optionselector("transcodingOptions").selectedIndex = localStorage.getItem("transcoding");
有人知道我想要达到的正确方法吗?
谢谢。