【问题标题】:jQuery and SPServices not showing jQuery spinnerjQuery 和 SPServices 未显示 jQuery 微调器
【发布时间】:2012-07-13 15:31:29
【问题描述】:

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

我在几页上阅读了您必须设置 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();
});

【问题讨论】:

    标签: jquery jquery-plugins jquery-mobile


    【解决方案1】:

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

    【讨论】:

    • 工作完美,并将其保留为async: true 供任何阅读本文的人使用
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-02
    • 2010-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-08
    相关资源
    最近更新 更多