jQuery Mobile嵌套列表-后退按钮消失了吗? [英] Jquery Mobile nested list - Back button gone?

查看:99
本文介绍了jQuery Mobile嵌套列表-后退按钮消失了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在最新版的jQu​​ery Mobile中,添加后退按钮的方法是在整个页面" div中添加"data-add-back-btn ="true"".

In the latest build of jQuery Mobile, the way to add a back button is by adding 'data-add-back-btn="true"' to your overall "page" div.

这很好用.但是,在查看嵌套列表子菜单时,后退按钮不再存在.

This works great. However, When viewing a nested list submenu the back button is no longer there.

通过查看输出代码,看来发生了什么事,jquery mobile正在隐藏原始的"page" div,并创建一个新的(没有将back button属性设置为true).

By looking at the output code, it seems whats happening is, jquery mobile is hiding your original "page" div, and creating a new one (without the back button attribute set to true).

我目前没有演示URL,但是您可以在演示页面 http://jquerymobile.com/test/docs/lists/lists-nested.html

I dont have a demo URL at this time, but you can see the issue in action at the demo page http://jquerymobile.com/test/docs/lists/lists-nested.html

我的问题是,我需要添加一些内容,告诉它为嵌套菜单添加一个后退按钮吗?如果没有,是否可以通过某种方式自动将后退按钮属性添加到所有页面" div中?

My question is, is there something I need to add, that will tell it to add a back-button for nested menus? and if not, is there some way I can hack it to automatically add the back-button attribute to all "page" divs?

感谢对此问题的任何帮助.

Appreciate any help on this is issue.

推荐答案

类似的方法应该有所帮助:

Something like this should help:

$(':jqmData(url^=MYPAGEID)').live('pagebeforecreate', 
  function(event) {
    $(this).filter(':jqmData(url*=ui-page)').find(':jqmData(role=header)')
      .prepend('<a href="#" data-rel="back" data-icon="back">Back</a>')
  });

MYPAGEID替换为包含列表的页面的ID.

Replace MYPAGEID with the ID of the page containing the list.

将在动态创建子页面时触发该事件,并将后退按钮作为标题中的第一项插入.之后,当jQueryMobile魔术自动运行时,它将被拾起并变得很好.

The event will be triggered when the sub page is dynamically created and will insert the back button as the first item in the header. That will then be picked up and made nice when the jQueryMobile magic is run automatically afterward.

过滤有点奇怪,因为您不能在第一个选择器中引用ui-page(它偶然发现了data-url中的&,看来您不能在)如果没有这种额外的过滤,您也会在父页面上获得后退按钮.

The filtering is a little odd because you can't reference the ui-page in the first selector (it stumbles over the & in the data-url and it appears you can't use a filter before the .live()) Without this extra filtering you get the back button on the parent page as well.

这篇关于jQuery Mobile嵌套列表-后退按钮消失了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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