无法调用初始化之前的方法;试图调用方法'刷新' [英] Cannot call methods prior to initialization; attempted to call method 'refresh'
问题描述
我想通过点击菜单中的项目更新链接按钮的值。
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:
jQueryMobile:
$('#selected').hide();
$("#menu li a").on('click',function(){
$('#selected').html($(this).html()).slideDown().button("refresh");
});
文本更新工作正常,但按钮的CSS不能正常更新。
Text update works fine, but button css is not properly updated.
我收到以下错误:
未捕获的错误:不能调用初始化之前按钮的方法;
试图调用方法刷新
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?
编辑:
我也试过这样的:
$(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 :(
推荐答案
这个问题有时是jQuery的-UI和引导按钮插件冲突引起的。
jQuery的的UI code bootstrap.js之前应该去,而且解决问题。
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屋!