【发布时间】:2015-05-08 18:06:33
【问题描述】:
我想设置一个 jQuery Mobile 翻转开关的选定值:
<select id="quote" data-role="flipswitch" data-theme="b">
<option value="nee">Nee</option>
<option value="ja">Ja</option>
</select>
执行以下操作时出现错误:
$("#quote").val('nee').flipswitch('refresh');
“在初始化之前不能调用flipswitch上的方法”
我也试过了:
$("#quote").val('nee').slider().flipswitch('refresh');
$("#quote").val('nee').flipswitch().flipswitch('refresh');
我怎样才能做到这一点?
【问题讨论】:
-
使用 jQM,您不使用 document.ready()。请改用 pagecreate 或 pagecontainer 小部件的事件之一。这是一个演示:jsfiddle.net/ezanker/9st8ytco/1
-
我的翻转开关在 jqm 弹出窗口中。这会导致问题吗?
-
应该没有区别:jsfiddle.net/9st8ytco/2 你能让小提琴重现这个问题吗?
-
也许我没有以正确的方式应用 JQM? apps.opolo.nl/geloofshelden/index.html
-
无法访问该网站 - 403 禁止
标签: javascript jquery html jquery-mobile jquery-mobile-flipswitch