Stop showing page

后端 未结 4 1988
后悔当初
后悔当初 2020-11-30 15:19

I want to do something like this:

$(document).on(\"pagebeforeshow\", \"#myPage\", function(event){ 
  if(condition){
    //I need to do something here to sto         


        
4条回答
  •  [愿得一人]
    2020-11-30 16:07

    I know if I use "pagebeforechange" event it works fine, but i need doing it when the other page is loaded (but not shown). I've found a solution adding a new DIV element as a page DIV child, hiding and showing it:

    HTML

    ...

    JS

    $(document).on("pagebeforeshow", "#myPage", function(){
       $("#contentTarget1").hide();
    
       if(condition){
          $.mobile.changePage("#target2Page");
       } else {
          $('#contentTarget1').show();
          ...
       }
    });
    

提交回复
热议问题