jquery-mobile - jQuery Mobile : Uncaught cannot call methods on checkboxradio prior to initialization; attempted to call method 'refresh'

标签 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('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出现(作为对话框)并显示每个选中的复选框。

这是发生问题的地方。当我在对话框中按“后退”按钮返回上一页并尝试取消选中这些复选框时,错误弹出,如标题中所述。我的代码中没有对“刷新方法”的调用,因此我看不到解决此问题的方法。
  • 任何人都可以提出解决此问题的方法吗?
  • 我使用的对吗? (我对jQuery Mobile非常陌生。如果使用JQM背后有一些概念,请向我解释[我尝试阅读JQM Docs,对我来说似乎不太清楚])。

  • 最好的问候,非常感谢您的回答。

    最佳答案

    您正在使用哪个版本的jQueryMobile?您可能需要使用pageinit而不是pagecreatejQueryMobile documentation的这一部分讨论选择。

    对于重新绘画或创建,solution that @Taifun指出,它类似于:

    $("input[type='radio']").checkboxradio();
    $("input[type='radio']").checkboxradio("refresh");
    对我来说还可以,但它不能正确地绘制控件的100%。单选按钮的边缘未涂圆角。

    在我看到您的代码之前,我read here可以在容器对象上调用.trigger('create'),它对我有用。您正在执行此操作,但是在pagecreate内部而不是pageinit中。

    关于jquery-mobile - jQuery Mobile : Uncaught cannot call methods on checkboxradio prior to initialization; attempted to call method 'refresh' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12691780/

    相关文章:

    android - 打开/关闭面板时对 ui-panel-dismiss 的淡入淡出效果(如 Android)

    javascript - 如何正确重定向到 Jquery Mobile 中的动态页面?

    ssis - 刷新 Integration Services 中的目标架构元数据

    ios - 使用简单的 Storyboard应用程序获取 SIGABRT 错误

    jquery-ui - 多行多级列表

    jquery-mobile - MVC4 Controller 中的 IEnumerable<HttpPostedFileBase> 集合始终为 null

    asp.net - 当其他 updatepanel 刷新 updatepanel 时,通过触发器刷新 updatepanel,因为第一个必须具有 UpdateMode=Conditional

    jquery 移动更新 anchor 文本

    objective-c - [__NSCFType searchKeyword :]: unrecognized selector sent to instance 0x6d8eb80

    java - 未捕获的异常处理程序 - UiAutomator