Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery mobile jQuery Mobile:Uncaught无法在初始化之前调用checkboxradio上的方法;试图调用方法';刷新';_Jquery Mobile_Refresh_Uncaught Exception - Fatal编程技术网

Jquery mobile jQuery Mobile:Uncaught无法在初始化之前调用checkboxradio上的方法;试图调用方法';刷新';

Jquery mobile jQuery Mobile:Uncaught无法在初始化之前调用checkboxradio上的方法;试图调用方法';刷新';,jquery-mobile,refresh,uncaught-exception,Jquery Mobile,Refresh,Uncaught Exception,我正在竭尽全力处理这个问题。 这些是我使用的代码,导致了上述问题 $(document).ready(function () { $("#at-site-btn").bind("tap", function () { $.mobile.changePage("view/dialog/at-site.php", { transition:"slidedown", role:"dialog" }); }); $('#at-site-page').live('p

我正在竭尽全力处理这个问题。 这些是我使用的代码,导致了上述问题

$(document).ready(function () {
    $("#at-site-btn").bind("tap", function () {
        $.mobile.changePage("view/dialog/at-site.php", { transition:"slidedown", role:"dialog" });
    });
    $('#at-site-page').live('pagecreate', function(){
        var $checked_emp    = $("input[type=checkbox]:checked");
        var $this           = $(this);
        var $msg            = $this.find("#at-site-msg");
        $checked_emp.appendTo($msg);
        $checked_emp.trigger('create');
        $msg.trigger('create');
        $(document).trigger('create');
        $this.trigger('create');
        $("html").trigger('create');

    });
});
说明:

上面的代码位于一个名为hod.php的文件中。该文件包含多个复选框。可以同时选中这些复选框,当我按下#at site btn按钮时,会出现at-site.php(作为对话框)并显示每个选中的复选框

这就是问题发生的地方。当我按下对话框中的后退按钮返回上一页并尝试取消选中这些复选框时,错误弹出,如标题中所述。我的代码中没有对“refresh method”的调用,因此我看不到解决此问题的方法

  • 有谁能提出解决这个问题的办法吗
  • 我用对了吗?(我对jQuery Mobile非常陌生。如果使用JQM背后有一些概念,请向我解释一下[我试过阅读JQM文档,但我似乎不太清楚])

  • 非常感谢您的回答。

    您使用的是什么版本的jQueryMobile?您可能需要使用
    pageinit
    而不是
    pagecreate
    。这部分讨论的是选择

    对于重新绘画或创作,作者指出,这看起来像:
    $(“输入[type='radio'])。checkboxradio();
    $(“输入[type='radio'])。复选框radio(“刷新”)
    对我来说效果不错,但它没有100%正确地绘制控件。单选按钮的边缘没有涂上圆角

    在我看到您的代码之前,我建议您可以在容器对象上调用
    .trigger('create')
    ,它对我很有用。您正在这样做,但是在
    pagecreate
    中,而不是在
    pageinit
    中,我实际上使用了一个:


    查看我的完整答案。

    可能也能帮助您…@Taifun-感谢您为我指出解决方案 $("input[type='radio']").checkboxradio(); $("input[type='radio']").checkboxradio("refresh");
    <div class="some-checkbox-area">
        <input type="checkbox" data-role="flipswitch" name="flip-checkbox-lesson-complete"
               data-on-text="Complete" data-off-text="Incomplete" data-wrapper-class="custom-size-flipswitch">
    </div>
    
    $("div.ui-page-active div.some-checkbox-area div.ui-flipswitch input[type=checkbox]").attr("checked", true).flipswitch( "refresh" )