【问题标题】:Refresh a jQuery Mobile flipswitch刷新 jQuery Mobile 翻转开关
【发布时间】:2014-04-22 10:16:30
【问题描述】:

我正在使用 jQuery Mobile,我尝试刷新 flipswitch 但当我尝试这样做时 $("#flipEnabled").slider("refresh");

我在控制台中遇到错误:Uncaught Error: cannot call methods on slider prior to initialization; attempted to call method 'refresh'

这个问题有解决办法吗?

【问题讨论】:

  • 你什么时候调用它?请分享更多细节。
  • 详细信息还不够......但似乎你在 ("#id").slider(); 之前调用滑块刷新;
  • 在 $(document).on("pagecreate")
  • 我发现:$("#flipEnabled").slider().slider("refresh");谢谢
  • 这个阶段不需要刷新,调用.slider()就够了。

标签: javascript jquery jquery-mobile refresh jquery-mobile-flipswitch


【解决方案1】:

尝试以下方法:

if (!$('#flipSwitch').checked) {
    $('#flipSwitch').prop('checked', false);
    $('#flipSwitch').flipswitch('refresh');
}

【讨论】:

    猜你喜欢
    • 2014-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多