jquery mobile Dynamically Injecting Pages

前端 未结 2 993
孤城傲影
孤城傲影 2020-12-12 00:38

I\'m using jQuery mobile and currently build a menu on the fly using the code below. I now need to create actual pages for menu items as my next step. I have been looking at

2条回答
  •  难免孤独
    2020-12-12 01:23

    There is a cashing problem if you want to recreate the page with new content. So you must do this...

    var $i = 0;
    $('#test').on('click', function () {
    	$i++;
      alert("I="+$i);
        // Prepare your page structure
        var newPage = $("
    Back

    Dynamic Page

    Stuff here = " + $i + "
    "); // Append the new page into pageContainer newPage.appendTo($.mobile.pageContainer); // Move to this page by ID '#page' $.mobile.changePage('#page'); }); $(document).on('pagehide', '#page', function(){ $(this).remove(); });
    test

提交回复
热议问题