1

im new in this community, first sorry for my bad english am from venezuela, my question is the follow. Im developing a jquery mobile aplication with a header menu animate whith jquery, the proyect is a single page HTML document contain many "page" container, in the first load works fine, but when change the page with $.mobile.changePage() the menu work wrong.

the header html

<div data-role="header" data-position="fixed" style="text-align:center;">
   <div id="navigation">
      <div class="home" style="height:100%">
         <div class="cls" style="height:100%;"></div>
         <div class="cls2" style="height:100%;"></div>
         <div class="cls3" style="height:100%;"></div>
         <div class="cls4" style="height:100%;"></div>
         <div class="cnf" style="height:100%;"></div>
      </div>
   </div>
    <h1 id="title" style="padding:4px;"></h1>

   <div id="navigation2">
      <div class="home2" style="height:100%">
         <div class="home2" style="height:100%">
            <div class="img" style="height:95%;"></div>
            <div class="cls" style="height:95%;"></div>
            <div class="cls2" style="height:95%;"></div>
            <div class="cls3" style="height:95%;"></div>
            <div class="cls4" style="height:90%;"></div>
         </div>
      </div>
   </div>
</div>

the javascript

 $('div.cnf').bind('click',function(e) {
    e.preventDefault();
    if (click === null) {          
        $('div.home').stop(true, true).animate({
            'marginLeft' : '+=80%'
        }, 1000);
        click = 1;

    }else{            
        $('div.home').stop(true, true).animate({
            'marginLeft' : '-=80%'
        }, 1000);
        resetmenu();
    }

});

$('div.home2').toggle(function(e) {
    e.preventDefault();
    $(this).stop(true, true).animate({
        'marginLeft' : '-=80%'
    }, 1000);

}, function() {       
    $(this).stop(true, true).animate({
       'marginLeft' : '+=80%' 
    }, 1000);

});
Tushar Gupta - curioustushar
  • 58,085
  • 24
  • 103
  • 107

1 Answers1

1

When using $.mobile.changePage(), understand that you are not actually "changing" to that page and you are not processing any of the scripts in the head tag. In JQM, when you use changePage() JQM goes and gets all the HTML starting at the first data-role="page" in the speficied file (bypassing the head section).

Really good link here: Jquery Mobile - $.mobile.changepage not loading external .JS files

Hope that helps

~Red

Community
  • 1
  • 1
Red2678
  • 3,177
  • 2
  • 29
  • 43