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.

  • 1
    Check this similar question (http://stackoverflow.com/questions/7729729/jquery-mobile-binding-to-pageinit-event)[http://stackoverflow.com/questions/7729729/jquery-mobile-binding-to-pageinit-event] – Bertrand Mar 21 '13 at 19:09
  • If it is not a problem, mail me your pages and js file and I will fix it for you? – Gajotres Mar 21 '13 at 19:14
  • Thanks for that link Bertrand, and the help offer Gajotres. I was able to find the problem. – DrJonOsterman Mar 21 '13 at 22:21

2 Answers2

1

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.

KPheasey
  • 1,765
  • 16
  • 22
0

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

Community
  • 1
  • 1