ok1ha
ok1ha

Reputation: 637

jQuery Mobile window.resize() on data-role="page" load

I'm using jQuery Lazy Load with jQuery Mobile and it requires a 1px scroll to trigger the first image load. $(window).resize(); works just fine but it's only firing on the site load.

jQuery mobile uses div's that contain data-role="page" instead of separate pages. So the mobile site is essentially one page.

How would I trigger $(window).resize(); every time a new data-role="page" is loaded?

Upvotes: 1

Views: 3871

Answers (1)

Omar
Omar

Reputation: 31732

Bind your code to pageshow event.

$(document).on('pageshow', '[data-role=page]', function () { 
 $(window).resize();
});

Upvotes: 3

Related Questions