I have an ASP MVC3 application that runs fine (in VS 2010 debug) in FireFox 4 but when I run the app in IE8 I get a bunch of JScript error in jquery-1.5.1 and jquery.validate.unobtrusive.
In my _SiteLayout.cshtml I am including the JavaScript like this:
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/QMSCommon.js")" type="text/javascript"></script>
…
<!--bottom of layout page - just before /body -->
@(Html.Telerik().ScriptRegistrar().jQuery(false).DefaultGroup(group => group.Combined(true).Compress(true)))
When I run this app in IE8 I get “Microsoft JScript runtime error: ‘undefined’ is null or not an object” in jquery.validate.unobtrusive.min.js right away. If I continue I get “Microsoft JScript runtime error: Object doesn’t support this property or method” in JQuery-1-5-1.
Am I including the correct JS file – is the order correct (or significant)?
UPDATE:
I have isolated the problem to my Javascript (in QMSCommon.js). The entire contents of that file is here:
$(document).ready(function () {
//Make fields set to datePicker css class have a datepicker control
$('.datePicker').datepicker(
{ buttonImage: '/content/images/calendar_edit.png',
buttonImageOnly: true,
showOn: 'both'
});
});
If I comment out the datepicker portion my site works in IE8. Do you see anything with this code that IE8 doesn’t like?
Ok, well this is a little embarrassing. The initial problem was due to the fact that I was not including the jquery-ui script :-). Firefox did not throw an error, IE did, but not at .datepicker rather somewhere deep within jQuery which was throwing me off. Anyway.
Furthermore I have updated my code to get the JQuery stuff from Google:
Works great.