【问题标题】:jquerymobile pageinit() page hidden?jquerymobile pageinit()页面隐藏?
【发布时间】:2011-11-11 05:05:03
【问题描述】:
var $page = el.parents('div[data-role="page"]:visible');

pageinit() 上被调用对我来说显示为空。有谁知道从 JQM 访问元素高度的适当处理程序? (因为我需要在显示元素时运行 height())

谢谢。

【问题讨论】:

    标签: html jquery-mobile


    【解决方案1】:

    如果您想引用 jQuery Mobile 中当前显示的页面,则可以使用 $.mobile.activePage 属性。它存储了当前页面的一个jQuery对象。

    因此,要获取当前 <div data-role="page"> 元素的高度,您可以:

    var the_height = $.mobile.activePage.height();
    

    或者你可以得到<div data-role="content">部分的高度:

    var the_height = $.mobile.activePage.children('[data-role="content"]').height();
    

    这是文档中关于此的页面的链接(但是几乎没有关于此属性的信息,您可能仍想浏览该页面以查看 jQuery Mobile 内置的内容):http://jquerymobile.com/demos/1.0rc2/docs/api/methods.html

    【讨论】:

    • 感谢您的回答,对这个大声笑有点恼火。似乎 JQM 文档中有一些区域有点稀缺!他们需要一个更好的单页演示,我认为更详细
    【解决方案2】:

    嘿,我刚刚发现这里的实际问题是元素似乎没有 height(),直到调用 pageshow 处理程序(在 pageinit 之后运行)

    所以使用该处理程序来运行基于抓取现有高度等的任何事件

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-02-05
      • 1970-01-01
      • 1970-01-01
      • 2013-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多