jQuery mobile无法刷新collapsibleset [英] jQuery mobile cannot refresh the collapsibleset

查看:161
本文介绍了jQuery mobile无法刷新collapsibleset的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery mobile创建一个应用程序并加载其菜单和页面形成wordpress throw jsonp。
我以collapsibleset和listview的形式抄袭菜单,但我一直在收到错误。当我尝试通过此代码刷新collapsibleset时

I am creating an application using jQuery mobile and loading its menu and pages form wordpress throw jsonp. I am loding its menu in the form of collapsibleset and listview but i keep on getting errors. when I try to refresh the collapsibleset by this code

$(".childnev").html(list);
$.mobile.loading( 'hide');
$('.popupmenu').slideToggle('slow');

$(".childnev").collapsibleset('refresh');

$(".childsublist").listview().listview('refresh');

它给了我这个错误

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

当我尝试刷新此代码时。

And when i try to refresh by this code.

$(".childnev").html(list);
$.mobile.loading( 'hide');
$('.popupmenu').slideToggle('slow');

$(".childnev").collapsibleset();
$(".childnev").collapsibleset('refresh');

$(".childsublist").listview().listview('refresh');

它再次给我这个错误

TypeError: o[0] is undefined

我错过了什么或做错了什么?

Am I missing something or doing something wrong?

推荐答案

你需要做的就是添加这个

All you need to do is adding this


演示

Demo



$('[data-role=collapsible-set]').collapsibleset().trigger('create');

这将增强 [data-role = listview] 活动页面)的c $ c>和 [data-role = collapsible-set] 。您可以使用任何选择器替换 $('[data-role = collapsible-set]')

This will enhance markup of [data-role=listview] and [data-role=collapsible-set] for the current page (active page). You can replace $('[data-role=collapsible-set]') with any selector.


  • 基于评论,你有很多错误。 .ready 不应与jQuery Mobile一起使用。此外, .live 不再使用,因此,将 .live 替换为 .on

  • Based on the fiddle in your comment, you have many mistakes. .ready shouldn't be used with jQuery Mobile. Also, .live is no longer use, hence, replace .live with .on.

增强方法刷新创建 pagecreate updatelayout 用于当前页面(活动页面 - $ .mobile.activePage )重新应用jQuery Mobile样式。对于动态创建且在DOM中创建的页面,不需要使用任何增强方法 - 甚至不需要 .page() pagecreate - 因为页面及其内容一旦放入DOM就会得到增强。

Enhancement methods refresh, create, pagecreate and updatelayout are meant to be used for current page (active page - $.mobile.activePage) to re-apply jQuery Mobile style. For pages created dynamically and are in DOM, there is no need to use any enhancement method - not even .page() or pagecreate - because pages and their contents get enhanced once placed into DOM.

这篇关于jQuery mobile无法刷新collapsibleset的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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