Solved: Trouble using ajax. Same page transition?
in jQuery Mobile
•
11 years ago
Hi
I have trouble getting ajax to work. I want to get it working to speed things up and reduce calls to the database.
I have a document BeobEdit.html. It contains a page (data-role="page") with id="BeobEditPage" and a url, for example http://barbalex.iriscouch.com/evab/_design/evab/_show/BeobEdit/8c3c2f45fd2560a0f9b2fa9d2b001990.
When the user swipes right (or left) the same document is shown with the same page but a different url and data, for example http://barbalex.iriscouch.com/evab/_design/evab/_show/BeobEdit/5ce10d6c6376b4d4b9bd38f1f80159aa.
When I change pages using "window.open(url, target='_self')" it works perfectly.
When I use "$.mobile.changePage(url)" the first page works fine but if I swipe on then in the next pages lots of stuff does not work. Seems like event listeners dont work. They work after a refresh of the page.
I have put all the page specific code inside a $(":jqmData(role='page')").on("pageinit", function() callback inside the page div to make sure it is called every time the page is showed. I have also tried the pagebeforeshow event and others. I also use the same page headers on all pages.
I have tried a lot of stuff and read through many similar problems but I can't get my page to work using changepage.
Then I realized that while changing pages, both pages are the same .html file and the same data-role=page although a different url (calling different data from couchdb). Could this be the reason for my problems? I have tried using { allowSamePageTransition: 'true', reloadPage: 'true' } in changepage but that does not solve the problem.
I am not sure what the docs mean with same page. Is it same .html file, same data-role=page or same url?
If you look at the links, please log in using user = z and password = z (the site uses window.open now, so it works).
I am using jQuery mobile 1.1.0 RC2. Had the same issues with prior versions.
I am also using mustache for templates (https://github.com/janl/mustache.js).
Does this maybe influence the behaviour?
Thanks for any hints
Alex
1