【发布时间】:2011-11-11 05:05:03
【问题描述】:
var $page = el.parents('div[data-role="page"]:visible');
在pageinit() 上被调用对我来说显示为空。有谁知道从 JQM 访问元素高度的适当处理程序? (因为我需要在显示元素时运行 height())
谢谢。
【问题讨论】:
标签: html jquery-mobile
var $page = el.parents('div[data-role="page"]:visible');
在pageinit() 上被调用对我来说显示为空。有谁知道从 JQM 访问元素高度的适当处理程序? (因为我需要在显示元素时运行 height())
谢谢。
【问题讨论】:
标签: html jquery-mobile
如果您想引用 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
【讨论】:
嘿,我刚刚发现这里的实际问题是元素似乎没有 height(),直到调用 pageshow 处理程序(在 pageinit 之后运行)
所以使用该处理程序来运行基于抓取现有高度等的任何事件
【讨论】: