I am currently working on an app based on jQuery Mobile. We choose it because on that moment it was looking so shiny and tasty, but as more I am working on it, more I'm getting stuck on multiple things.
I created all pages separately and they was working fine, but after linked them with each others I start to getting some difficulties.
For each page I need to load different scripts and 3rd party libraries, after some research i came up with adding id's for data-role="page" and load them with .delegate(), but that giving me one troubles, so question:
1) How to unbind/kill/clear/remove all loaded scripts when you moving to another page?
Problem is, that when I am going to "page 2" and do:
$(document).delegate('#page-2', 'pageinit', function() {
...do something
});
after going to "page 1" or "page 3" the stuff loaded with #page-2 .deligate() stays in DOM and conflicting with scripts on another pages.
P.S. Messy but whole file can be seen here - http://cloud.ignatynikulin.com/011R3x2k401i271N420N
P.P.S. A quick update for one more question:
Why if condition is not working inside .deligate() pageInit and how to make it work?
Thank you