My code when run in Chrome or Firefox worked as intended. However in Internet Explorer an error is picked up. Unfortunately the debugger only gets the top level from the call stack, meaning it will pick up the line number of the first function call in my own scripts, and line 3 out of 4 for the compressed jQuery. Furthermore the error is the confusing:
Object doesn’t support this property or method
Which looks weird when linked in the jQuery source; neither error is for a line which called an object method. The function whose call in my scripts is given as the line number of the bug is as follows:
$('title').text('Student accommodaton in '+loc.title);
$('fieldset.search').data('loc',loc.loc_id).find('p.locs').slideUp().end().find('ul.blurb').hide();
$('nav.top').find('li.index a').attr('href',loc.url)
.end().find('p.user').addClass('show');
$('header.title').find('h2').each(function(loc){
return function(){
$(this).data('text',$(this).text()).text('Student accommodation in '+loc.title);
}
}(loc))
.end().find('p').fadeIn();
$('section.register h3:first').textPrepend('Scroll down and ');
It turned out that the error was caused by the following code
I found this out through deleting lines one at a time as I’m using IETester which has no decent debugging software. Whereas the following code:
Would correctly indicate that the returned object (a text string) didn’t have the method
.text()it seems that using$('title')returns a more abstract error as jQuery tries to apply the method. Hence the line number of the bug was wrong as it propagated back up the function stack.In short, when changing a title use
And if you get errors showing up in the jQuery source look first for any odd selectors or
<head>element selectors which you might be using.