So I am trying to implement the solution suggested to me in my previous question (http://stackoverflow.com/questions/1586998/). I want to use the Cycle library found here: http://malsup.com/jquery/cycle2/ to cycle through the contents of a DIV that I am populating with rows from a custom SharePoint list. The html I am creating appears to be valid, but when I try to run the cycle code below I get:
Error: $("#tasksUL").cycle is not a function
Source File: http://ourdomain.net/Pages/Default.aspx
Line: 426
Here is the code I have blocked into a Content Editor Web Part:
<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"> </div>
The code is firing off as expected, but I am wondering what I am doing wrong with regards to the Cycle function... I have tryed explicitly linking to all of the JavaScript files in the includes I have above, and I can reach them in a browser no problems. In order to use this library correctly, do I need to actually define CSS for #tasksUL ? Is there anything obvious in the code that I need to punch in the face? Thanks!