问题描述
我想通过单击菜单项来更新链接按钮的值.
HTML:
<ul data-role="listview" data-icon="false"><li><a href="#">值A</a></li><li><a href="#">值B</a></li><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:
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.
这篇关于不能在初始化之前调用方法;试图调用方法“刷新"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!