Stop showing page

后端 未结 4 1991
后悔当初
后悔当初 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条回答
  •  旧时难觅i
    2020-11-30 16:17

    I think the best way to do this would be to have the page hidden by default, and only show it if it passes the conditional. So it would look like this

    CSS:

    #myPage {
      display: none;
    }
    

    JS:

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

提交回复
热议问题