0

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

ignaty
  • 535
  • 1
  • 4
  • 18

2 Answers2

0

Not quite the answer, but could you move some pages in separate files? In my case, I am using separate aspx files if I want to edit items displayed in a list. For example,

<ul data-role="listview">
  ...
  <li>
    <a href="ItemPage.aspx?Id=1" rel="external">Item1</a>
  </li>
  ...
</ul>
dan radu
  • 2,772
  • 4
  • 18
  • 23
0

I guess your question is about how to remove loaded script from DOM.

Found an existing question in the same line: Is the javaScript not part of the DOM?

Community
  • 1
  • 1
Priya Kathir
  • 263
  • 1
  • 6