不能在初始化之前调用方法;试图调用方法“刷新" [英] Cannot call methods prior to initialization; attempted to call method 'refresh'

查看:29
本文介绍了不能在初始化之前调用方法;试图调用方法“刷新"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过单击菜单项来更新链接按钮的值.

HTML:

<a href="#" id="selected" data-role="button"></a>

jQueryMobile:

$('#selected').hide();$("#menu li a").on('click',function(){$('#selected').html($(this).html()).slideDown().button("refresh");});

文本更新工作正常,但按钮 css 未正确更新.

我收到以下错误:

<块引用>

未捕获的错误:无法在初始化之前调用按钮上的方法;试图调用方法刷新"

我们在谈论哪个初始化?页面和按钮已经初​​始化了,不是吗?

<小时>

我也试过这个:

$(document).on("mobileinit", function() {$('#selected').hide();$("#menu li a").on('click',function(){$('#selected').html($(this).html()).slideDown().button("refresh");});});

不再有错误信息;但没有文字更新:(

解决方案

该问题有时是由 jquery-ui 和 bootstrap-button 插件冲突引起的.jquery-ui 代码应该放在 bootstrap.js 之前,这样就解决了问题.

I'd like to update the value of a link-button by clicking on the item of a menu.

Html:

<div id="menu">
    <ul data-role="listview" data-icon="false">
        <li><a href="#">Value A</a></li>
        <li><a href="#">Value B</a></li>
    </ul>
</div>

<a href="#" id="selected" data-role="button"></a>

jQueryMobile:

$('#selected').hide();

$("#menu li a").on('click',function(){
    $('#selected').html($(this).html()).slideDown().button("refresh");
});

Text update works fine, but button css is not properly updated.

I get the following error:

Uncaught Error: cannot call methods on button prior to initialization; attempted to call method 'refresh'

Which initialization are we talking about ? Page and button are already initialized, aren't they?


EDIT:

I also tried this :

$(document).on("mobileinit", function() {

    $('#selected').hide();

    $("#menu li a").on('click',function(){
        $('#selected').html($(this).html()).slideDown().button("refresh");
    });

});

No error message any more; but no text update :(

解决方案

The issue is sometimes caused by jquery-ui and bootstrap-button plugins conflict. jquery-ui code should go before bootstrap.js, and that solves the problem.

这篇关于不能在初始化之前调用方法;试图调用方法“刷新"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆