Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquerymobile pageinit() page hidden?

var $page = el.parents('div[data-role="page"]:visible');

Being called on pageinit() is showing null for me. Does anyone know the appropriate handler to access elements height from JQM on? (As I need to run height() when the element is displayed)

Thanks.

like image 624
williamsandonz Avatar asked Mar 28 '26 23:03

williamsandonz


1 Answers

If you want a reference to the currently displayed page in jQuery Mobile there is the $.mobile.activePage property. It stores a jQuery object of the current page.

So to get the height of the current <div data-role="page"> element you would do:

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

Or you could get the height of the <div data-role="content"> section:

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

Here's a link to the page in the documentation about this (however there is almost no info for this property, you may still want to browse the page to see what jQuery Mobile has built-in): http://jquerymobile.com/demos/1.0rc2/docs/api/methods.html

like image 172
Jasper Avatar answered Apr 02 '26 23:04

Jasper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!