I've been having a lot of problems with jQuery 1.3.2 on only one of my sites. It's a Joomla site, so Mootools is included on the page as well (and it's too difficult to remove Mootools). Basically the problem is that calling the basic jQuery selector with one selector (eg: "a", ".myClass"
, not "html a", ".myClass td"
), will only return the first element.
I've stepped through the code and have narrowed it down to this function in the Sizzle engine:
(see for yourself, line 2058 jquery.js)
var makeArray = function(array, results) {
array = Array.prototype.slice.call( array );
if ( results ) {
results.push.apply( results, array );
return results;
}
return array;
};
I'll write it out here again with comments to show the values I've been logging after calling jQuery("a")
:
var makeArray = function(array, results) {
// "array" is an array of all the 58 links on the page
// "results" is an empty jQuery object
array = Array.prototype.slice.call( array );
// array is unchanged.
if ( results ) { // true
results.push.apply( results, array );
// "results" is now an array only holding the FIRST element.
return results;
}
return array;
};
Can someone explain this code to me? And also why it's getting rid of all but one of my elements??