jQuery Mobile - 切换时的$ .mobile.showPageLoading()

时间:2012-01-17 15:37:05

标签: jquery jquery-mobile

当你有$ .mobile.ajaxEnabled = false时,这是否可行; ?

我试过

$('.test').toggle(function() {
      $.mobile.showPageLoading()
});

2 个答案:

答案 0 :(得分:3)

这会有效吗?

JS

$('#toggle1').click(function() {
    // Happens to fast, will not show loading message
    $.mobile.showPageLoadingMsg();
    $('.booleanToggle').toggle();
    $.mobile.hidePageLoadingMsg();
});

$('#toggle2').click(function() { 
    $.mobile.showPageLoadingMsg();  
    $('.transitionToggle').toggle("slow", function() {
        // Animation complete, hide message
        $.mobile.hidePageLoadingMsg();
    });
});

HTML

<div data-role="page" id="home">
    <div data-role="content">
        <a href="#" data-role="button" id="toggle1">Toggle 1 (Boolean)</a>        
        <br />
        <div id="div1" class="booleanToggle">
Bacon ipsum dolor sit amet capicola chuck flank, pork loin ribeye prosciutto pork tail chicken ball tip frankfurter biltong pig. Rump boudin t-bone capicola shankle venison biltong. Meatloaf sirloin pork chop beef ribs short loin, tenderloin pork salami pastrami drumstick shankle ham hock frankfurter. Ham prosciutto sausage, spare ribs ham hock beef ribs frankfurter leberkase flank strip steak tongue. Boudin bacon pancetta, drumstick ham hock pork tenderloin biltong chuck pork belly ball tip short ribs tri-tip jowl. Ham pastrami tongue pork. Hamburger strip steak boudin turkey frankfurter flank ribeye, beef ribs turducken meatball fatback short ribs pork andouille tri-tip.
        </div>
        <div id="div2" style="display:none;" class="booleanToggle">
Strip steak ground round shankle, swine tri-tip cow ham hock. Pancetta meatloaf venison pork loin, pork swine shoulder jowl sirloin drumstick andouille turkey brisket. Meatloaf pork loin spare ribs biltong jowl, bresaola ham pastrami fatback tongue t-bone. Kielbasa shank pork belly flank tenderloin frankfurter. Corned beef ground round sirloin turducken frankfurter pastrami, filet mignon salami ball tip tongue tri-tip beef ribs. Rump jowl short loin, turkey corned beef sausage ham hock chuck. Tail shoulder prosciutto andouille pork, bresaola short loin biltong.
        </div>
        <br /><br />
        <a href="#" data-role="button" id="toggle2">Toggle 2 (Duration)</a>
        <div id="div3" class="transitionToggle">
Bacon ipsum dolor sit amet capicola chuck flank, pork loin ribeye prosciutto pork tail chicken ball tip frankfurter biltong pig. Rump boudin t-bone capicola shankle venison biltong. Meatloaf sirloin pork chop beef ribs short loin, tenderloin pork salami pastrami drumstick shankle ham hock frankfurter. Ham prosciutto sausage, spare ribs ham hock beef ribs frankfurter leberkase flank strip steak tongue. Boudin bacon pancetta, drumstick ham hock pork tenderloin biltong chuck pork belly ball tip short ribs tri-tip jowl. Ham pastrami tongue pork. Hamburger strip steak boudin turkey frankfurter flank ribeye, beef ribs turducken meatball fatback short ribs pork andouille tri-tip.
        </div>
        <div id="div4" style="display:none;" class="transitionToggle">
Strip steak ground round shankle, swine tri-tip cow ham hock. Pancetta meatloaf venison pork loin, pork swine shoulder jowl sirloin drumstick andouille turkey brisket. Meatloaf pork loin spare ribs biltong jowl, bresaola ham pastrami fatback tongue t-bone. Kielbasa shank pork belly flank tenderloin frankfurter. Corned beef ground round sirloin turducken frankfurter pastrami, filet mignon salami ball tip tongue tri-tip beef ribs. Rump jowl short loin, turkey corned beef sausage ham hock chuck. Tail shoulder prosciutto andouille pork, bresaola short loin biltong.
        </div>
    </div>
</div>

答案 1 :(得分:0)

我认为你很可能必须在pageinit中这样做。主要的是加载器必须在页面转换之前加载

$('#yourid').live('pageinit',function(event){
  $.mobile.showPageLoading()
});