无法调用初始化之前的方法;试图调用方法'刷新'

编程入门 行业动态 更新时间:2024-10-26 02:31:44
本文介绍了无法调用初始化之前的方法;试图调用方法'刷新'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想通过点击菜单中的项目更新链接按钮的值。

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.

更多推荐

无法调用初始化之前的方法;试图调用方法'刷新'

本文发布于:2023-11-06 07:49:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1563115.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方法   初始化

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!