In the following code, I included an attribute for debugging. In FF and Chrome, I get a ton of alerts saying "attribute found", but in IE, I get nothing. The function returns an empty array.
I have also tried removing the console.info(this)
line.
BTW, I'm using SPServices to access lists from SharePoint 2010 -- I'm trying to get all the columns of a list.
/*!
* listAttributes jQuery Plugin v1.1.0
*
* Copyright 2010, Michael Riddle
* Licensed under the MIT
* http://jquery.org/license
*
* Date: Sun Mar 28 05:49:39 2010 -0900
*/
//THIS ISN'T WORKING IN IE
if(jQuery) {
jQuery(document).ready(function() {
jQuery.fn.listAttributes = function(prefix) {
var list = [];
var attributes = [];
$(this).each(function() {
console.info(this);
for(var key in this.attributes) {
alert("attribute found");
if(!isNaN(key)) {
if(!prefix || this.attributes[key].name.substr(0,prefix.length) == prefix) {
attributes.push(this.attributes[key].name);
}
}
}
list.push(attributes);
});
return attributes;
}
});
}
//end listAttributes Plugin - use this to see what attributes
function ImportSPListColumnsToArray(ListName)
{
var ArrayForStorage = new Array();
$(document).ready(function() {
$().SPServices({
operation: "GetListItems",
async: false,
listName: ListName,
CAMLViewFields: "",
CAMLQueryOptions: "<QueryOptions><ViewAttributes Scope='RecursiveAll'/></QueryOptions>",
**completefunc: function (xData, Status) {
$(xData.responseXML).find("[nodeName='z:row']").each(function() {
//find all fields used by each row and aggregate them without duplicating
var row_attr = $(this).listAttributes();**
for (var i=0; i<row_attr.length; i++)
{
if ($.inArray(ArrayForStorage, row_attr[i]) == -1)
{
ArrayForStorage.push(row_attr[i]);
}
}
row_attr.clear();
});
}
});
});
return ArrayForStorage;
}