I have JS code like so:
var li = $("li[attribute=foo]");
if (li.length)
{
li.show("slow"); // Fails
}
I see:
Error: Object doesn't support this property or method
show() with no arguments works.
Same for fadeIn() or scrollUp(). I’ve also noticed closest() fail on another element. All these work in Firefox.
I’m suspicious that this is because the content in question is within an iframe (jquery itself is included in the outer page), but all other jquery in the iframe works, and from the IE debugger’s point of view, the li exists and has a show method available with arguments.
Any ideas what’s going wrong, or how to work around this, would be much appreciated.
As per the comments above, this was nothing to do with the version of jquery or the iframe, but was because of some JS on my page in the form:
It’s worth sharing how I solved this in case it helps anyone. The secret was to get the full version of jquery, not the obfuscated and compressed one, so I could debug more easily what was going wrong in jquery.
What I found was that in
Sizzle.filter, jquery iterates like so:The point is that jquery is expecting to find
ATTR,CHILD,CLASSetc as thetype. But it also findssomeCustomFunction. AndsomeCustomFunctiondoesn’t have anexec, so it falls over.The hack fix for now is to just introduce an empty
execmethod for jquery to find. e.g.Longer term, I’ll want to restrict
someCustomFunctionto where it’s actually required, rather than justObject.