jQuery “.Zyklus ist nicht eine Funktion" Fehler - follow-up von http://stackoverflow.com/questions/1586998/

So, ich bin versucht zu implementieren die Lösung, um mir in meiner vorherigen Frage (SharePoint SOAP GetListItems VS jQuery - Brauchen Sie einige Ratschläge, wie man Ajax verwenden, um durch eine Benutzerdefinierte Liste von Objekten als auch als Ajax-refresh-die Inhalte der Liste). Ich möchte die Verwendung der Zyklus-Bibliothek finden Sie hier: http://malsup.com/jquery/cycle2/ zum Blättern durch den Inhalt von einem DIV, dass ich füllen mit Zeilen aus einer benutzerdefinierten SharePoint-Liste. Die html ich bin erstellen scheint gültig zu sein, aber wenn ich versuche, führen Sie den Zyklus-code unten bekomme ich:

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

Hier ist der code, den ich geblockt habe in einem Inhalts-Editor-Webpart:

<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>

Den code feuern aus wie erwartet, aber ich Frage mich, was ich falsch mache mit Bezug auf die-Kreislauf-Funktion... ich habe versucht, explizit die Verknüpfung, um alle JavaScript-Dateien in den includes habe ich oben, und ich Sie erreichen kann in einem browser ohne Probleme. Um diese Bibliothek korrekt, muss ich tatsächlich definieren CSS für #tasksUL ? Ist es etwas, was offensichtlich in den code, dass ich zu Schlag ins Gesicht? Danke!

  • Sind Sie sicher, dass Sie mit der Cycle-plug-in (malsup.com/jquery/cycle) geladen?
  • Absolut! Die Dritte Zeile des JS im code oben ist ein include, das eigentlich gut funktioniert... gibt es noch andere Dateien, die ich brauchen könnte?
Schreibe einen Kommentar