0

そのため、以前の質問で提案されたソリューションを実装しようとしています ( SharePoint SOAP GetListItems VS jQuery - Ajax を使用してカスタム リスト項目を循環させ、Ajax でリストの内容を更新する方法についてのアドバイスが必要です)。http://malsup.com/jquery/cycle2/にあるサイクル ライブラリを使用して、カスタム SharePoint リストの行を入力している DIV の内容を循環させたいと考えています。私が作成している html は有効に見えますが、以下のサイクル コードを実行しようとすると、次のようになります。

Error: $("#tasksUL").cycle is not a function
Source File: http://ourdomain.net/Pages/Default.aspx
Line: 426 

コンテンツ エディター Web パーツにブロックしたコードは次のとおりです。

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="/SiteCollectionDocuments/jquery.timers-1.0.0.js"></script>
<script type="text/javascript" src="/SiteCollectionDocuments/jquery.cycle.all.2.72.js"></script>
<script type="text/javascript">

$(document).ready(function() {

// Create the SOAP request        
// NOTE: we need to be able to display list attachments to users, hence the addition of the
// <queryOptions> element, which necessitated the addition of the <query> element

var soapEnv =
"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'><soapenv:Body><GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'><listName>testlist</listName><viewFields><ViewFields><FieldRef Name='Title' /><FieldRef Name='Body' /><FieldRef Name='ID' /><FieldRef Name='Attachments' /></ViewFields> </viewFields><query><Query /></query><queryOptions><QueryOptions><IncludeAttachmentUrls>TRUE</IncludeAttachmentUrls></QueryOptions></queryOptions></GetListItems></soapenv:Body></soapenv:Envelope>";

// call this SOAP request every 20 seconds
$("#tasksUL").everyTime(20000,function(i){
    // our basic SOAP code to hammer the Lists web service
    $.ajax({
    url: "http://ourdomain.net/_vti_bin/lists.asmx",
    type: "POST",
    dataType: "xml",
    data: soapEnv,
    error: printError,
    complete: processResult,
    contentType: "text/xml; charset=\"utf-8\""
    });
  });
});

// basic error display that will pop out SOAP errors, very useful!
function printError(XMLHttpRequest, textStatus, errorThrown)
{
  alert("There was an error: " + errorThrown + " " + textStatus);
  alert(XMLHttpRequest.responseText);
}

// main method that will cycle through the SoAP response nodes
function processResult(xData, status) 
{
    var liHtml = "";
  $(xData.responseXML).find("z\\:row").each(function() 
  {
    // resets display element
    $("#tasksUL").empty();

    // gets attachments array - if there is more than one attachment,
    // they get seperated by semi-colons in the response
    // they look like this natively (just an example):
    // ows_Attachments = ";#http://server/Lists/Announcements/Attachments/2/test.txt;
    // #http://server/Lists/Announcements/Attachments/2/UIP_Setup.log;#"

        var mySplitResult = $(this).attr("ows_Attachments").split(";");
    // set up storage for later display of images
    var notice_images = "";

    // processes attachments - please forgive the kludge!  
    for(i = 0; i < mySplitResult.length; i++)
    {
        // check to see the proper link URL gets chosen
        if (i % 2 != 0 && i != 0)
        {
            // strips out pound sign
            mySplitResult[i] = mySplitResult[i].replace("#", "");

            // (possibly redundant) check to make sure element isn't simply a pound sign  
            if (mySplitResult[i] != "#")
            {
                // adds an img tag to an output container
                notice_images = notice_images + "<img src='" + mySplitResult[i] + "' border='0' align='right' style='float:right;' /><br />"; 
            }
        }
    }

    // create final output for printing
    liHtml = liHtml + "<div><h3>" + $(this).attr("ows_Title") + "</h3><p>" + notice_images + $(this).attr("ows_Body") + "</p></div>";
  });

    // assign output to DIV tags
  $("#tasksUL").html(liHtml);
}
</script>

<script type="text/javascript">
$(document).ready(function() {
    $('#tasksUL').cycle({
        fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
    });
});
</script>

<div id="tasksUL">&nbsp;</div>

コードは期待どおりに起動していますが、Cycle 関数に関して何が間違っているのか疑問に思っています...上記のインクルード内のすべての JavaScript ファイルに明示的にリンクしようとしましたが、ブラウザは問題ありません。このライブラリを正しく使用するには、実際に #tasksUL の CSS を定義する必要がありますか? 私が顔を殴る必要があるコードに明らかなものはありますか? ありがとう!

4

2 に答える 2

1

jquery.cycle...js はどこから入手しましたか?

少なくとも、jQuery Cycle Plugin ホームページの zip ファイルには、ファイル名の末尾に奇妙な文字が追加されているようです。解凍すると、jquery.cycle.all.min.js_代わりにファイルが呼び出されますjquery.cycle.all.min.js

于 2009-10-20T06:39:58.283 に答える
1

実際、誰もこれを知る方法はありませんでした。これが失敗した理由は、誰かが古いサイト コレクション jQuery パッケージをインストールしたためで、jCycle ではうまく機能しませんでした。コレクションでその機能を無効にし、IIS を再起動してページを更新すると、すべて正常に機能しました。追加の手順として、jQuery の最新のフル バージョンをドキュメント ライブラリにダウンロードし、Google がホストするバージョンのスクリプトの代わりにリンクしました。したがって、私が使用しているすべての js は、現在サイト コレクション内に存在します。

jQuery の競合するバージョンについては理解できましたが、Firebug のコンソールとスクリプト デバッガーを使用しました。すべてのエラーで停止するようにデバッガーを設定する必要がありましたが、最初に発生したエラーは、サイト コレクションの jQuery パッケージを参照していて、含まれている Google コードではありませんでした。それが私が自分の質問に答える理由です。SharePoint の開発を行っている貧しい野郎は他にもいますが、FireFox を使用して SP のインストールをテストすることは、IE などすべてに有利であることを考えると、彼らには思いつかないかもしれません。

読んで回答/コメントしてくれたすべての人に感謝します!

于 2009-10-21T07:14:14.490 に答える