0

我正在使用带有 SPServices 的 jQuery Mobile 将 SharePoint 数据拉入移动页面。所有数据都实际加载,但我没有成功让微调器在提取数据时加载。

我已经阅读了几页您必须设置async: true才能使其正常工作的页面,但这没有帮助。我还尝试了几种方法来显示和隐藏都不起作用的微调器。

有任何想法吗?

不工作

$(document).delegate('#top-stories', 'pageshow', function () {
    function getList(){
             // ....
    } // end function
    $.mobile.showPageLoadingMsg();
    getList();
    $.mobile.hidePageLoadingMsg();
});

不工作

$(document).delegate('#top-stories', 'pageshow', function () {
    function getList(){
        $.mobile.showPageLoadingMsg();
        $().SPServices({
            // ....
        });
        $.mobile.hidePageLoadingMsg();
    } // end function
    getList();  
});

加载项目和工作的代码,只是没有微调器

$(document).delegate('#top-stories', 'pageshow', function () {
    function getList(){
        $().SPServices({
            operation: "GetListItems",
            listName: "Posts",
            webURL: "/SiteDirectory/news_and_updates",
            async: true,
            CAMLRowLimit: 15,
            CAMLQuery: "<Query><OrderBy><FieldRef Name='Created' Ascending='FALSE' /></OrderBy><Where><Eq><FieldRef Name='PostCategory' /><Value Type='Choice'>Announcements</Value></Eq></Where></Query>",
            CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='ID' /></ViewFields>",
            completefunc: function (xData, Status) {
              $(xData.responseXML).SPFilterNode("z:row").each(function() {
                var liHtml = "<li data-theme=\"c\"><a href=\"javascript:viewStory(" + $(this).attr("ows_ID") + ")\">" + $(this).attr("ows_Title") + "</a></li>";
                $("#top-stories ul").append(liHtml).listview("refresh");
              });
            }
        });
    } // end function
    getList();
});
4

1 回答 1

2

在调用 $().SPServices 之前,在 getList 方法中调用 showPageLoadingMsg。然后在你的 completeFunc 回调方法中调用 hidePageLoadingMsg,在循环之前或之后通过 xData.responseXML;

于 2012-07-13T15:58:23.193 回答