DrJonOsterman
DrJonOsterman

Reputation: 139

Script does not run in JQuery Mobile 1.2.0

I have a script in a separate js file, which for now, contains

$('#page-seriesLevel').live('pageinit', function(){
   console.log(document.URL + ' loaded.');});

This is called from series.php ideally when the page is ready, and catalog.php links to series.php.

But when I go to that page from catalog.php, the script does not execute. I have to refresh to see it. Sometimes the script executes from catalog.php which it shouldn't.

Upvotes: 0

Views: 125

Answers (2)

DrJonOsterman
DrJonOsterman

Reputation: 139

I knew that JQM loads pages via ajax, but I didn't know that it just loads the element with data-role="page", ignoring the head (where my JS was), as this answer says. https://stackoverflow.com/a/7449731/677331

Upvotes: 0

KPheasey
KPheasey

Reputation: 1805

I'm a little confused about what your asking. If the problem is that the page load event, 'pageinit', is not triggered every time you go to the page, try using 'pagebeforeshow' or 'pageshow'. 'pageinit' is only triggered the first time you go to the page.

See the "page load events" section on http://jquerymobile.com/demos/1.2.0/docs/api/events.html for more information.

Upvotes: 1

Related Questions