0

I am having troubles with changing pages across my website with jquery mobile. Tough i switched back to the standard window.location, i would like to use changePage() og jquery mobile, but im facing some issues. When i click the link, the page changes, but the js attached doesn't reload, so im stuck with the content of the preveious page(or not event this). Ive tried different approches: pageReload:true (not working), changing the position of the script tag(works, but creates duplicate content). If anyone has some answers for my question, i'd be grateful. I dont think this issue needs snippets, but here they are:

HTML:

        <div class='ui-block-b'>       
            <a href='nota.php' data-role='button' class='buton_no_bg right' style='color:#b21908; font-family:'Segoe WP Semibold''>190 lei</a>
        </div>

Thank you.

Victor Bojica
  • 333
  • 1
  • 4
  • 14

1 Answers1

0

To understand this situation you need to understand how jQuery Mobile works. It uses ajax to load other pages.

First page is loaded normally. Its HEAD and BODY is loaded into the DOM, and they are there to await other content. When second page is loaded, only its BODY content is loaded into the DOM.

Solutions:

  1. Put all of your javascript into first HTML/PHP file
  2. Put your javascript into BODY, basically into page div
  3. Turn ajax off
Community
  • 1
  • 1
Gajotres
  • 57,309
  • 16
  • 102
  • 130
  • Then you still have 2 available solutions. If you want to be safe go with solution 2. – Gajotres May 25 '13 at 14:58
  • did that and i get duplicate content – Victor Bojica May 25 '13 at 15:40
  • How did you managed to get duplicated content? Recheck your code, and if you want us to help you post some code. – Gajotres May 25 '13 at 17:20
  • i have solved somehow the problem(the script reloads), but it executes the code for both the current page and preveious page... i guess its because the new page the i was redirected its loaded in DOM and the script runs for it too... i will post in a few mins the code. thanks. – Victor Bojica May 25 '13 at 19:23