I have a few pages made with jquery mobile. These pages are all separate files, such as register.php. Each file has one “page”, as in the literal jquery mobile div.page.
When I click a link, ajax calls this new file and extracts the div.page — rather than loading the new page like a standard link would.
I have a function, which was originally bound to the onload event for a specific page (register.php). Now, because it’s being pulled in with ajax instead of loading a new page, the javascript for that page never fires.
I need to use pageinit() or pagecreate() according to JQM docs – but they don’t explain how to do this…
I need to bind one of those events, probably pagecreate as I need to use my function after all elements are ready. But how do I distinguish one page from another using the same script?
If I have a link to register.js in my <head> for register.php only, it isn’t even used when pulled in via ajax – because it only pulls in the <body>.
Let’s say I have a function called register_form(). How do I call this every time register.php is opened? This includes clicking the back button.
I looked here, jQuery Mobile – pageinit and pagecreate only firing once. However, when you go to a different page the ID of the new page is not added.
I believe it’s (unless they’ve changed it since I last used jqm)…