如何在phonegap转换后给出加载屏幕时消失

时间:2015-10-02 11:52:58

标签: android jquery cordova

我正在开发一个应用程序,其中我需要提供加载屏幕直到页面转换(导航)然后在导航后停止显示加载屏幕。但加载屏幕仍然显示甚至在转换后。如何在转换后停止显示它?

html的

  function gotonextscreen() {
        document.getElementById('loading').style.display = "block";

        if (location == false) {
            jAlert("Please make sure GPS is enabled. Please try again.");
        }
        else {
             //document.getElementById('loading').style.display = "none";
            $('#iframe').height(screen.height);

            document.getElementById("iframe").innerHTML = '<iframe style="width: 100%; height: 80%;" width="75%" height="75%" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&amp;q=hospital&aq=&amp;sll=' + x + ',' + y + '&amp;sspn=0.040066,0.077162&ie=UTF8&hq=hospital&hnear=&amp;t=m&ll=' + x + ',' + y + '&amp;spn=0.007705,0.008669&z=14&output=embed"></iframe><br /><small><a href="https://maps.google.com/maps?f=q&source=embed&hl=en&geocode=&amp;q=hospital&aq=&amp;sll=' + x + ',' + y + '&amp;sspn=0.040066,0.077162&ie=UTF8&hq=hospital&hnear=&amp;t=m&ll=' + x + ',' + y + '&amp;spn=0.007705,0.008669&z=14" style="color:#0000FF;text-align:left"></a></small>';
            $.mobile.changePage('#Page', {
                transition: "none",
                reverse: false,
                changeHash: false
            });
            currentPage = 'Page';
            pageData.push(currentPage);
$('#loading').hide();
        }

    }

的.js

{{1}}

1 个答案:

答案 0 :(得分:0)

我没有用jquery mobile做过很多,但是一个选项是在页面加载后尝试进行回调。

在您的情况下,您可以尝试以下方式:

$('#Page').live('pageshow', function(event, ui) {
    $('div#loading').hide();
});

在您更改页面之前放置它,看它是否有效。 上面的代码段基本上绑定了'#Page'的'liveshow'上的事件处理程序,所以当'#Page'呈现时你可以尝试隐藏加载栏。

This回答提供了一个很好的示例,说明如何在页面加载后进行回调。