0

I am trying to implement an MVC3 DatePicker but having trouble. I have the following code:

<script type="text/javascript"> /// <reference path="jquery-1.5.1.js" />/// <reference path="jquery-ui-1.8.11.js" /> $(document).ready(function () { $('.date').datepicker({dateFormat: "dd/mm/yy"});}); </script> <div> @Html.TextBox("SRRDate", Model.SRRDate.ToString(), new { @class = "date" }) Start Date </div> 

However, I am getting an "Microsoft JScript runtime error: Object doesn't support this property or method" in jquery-1.5.1-min.js

Any ideas?

1
  • Are you including both jQuery and jQuery UI files? Commented Oct 24, 2011 at 14:11

2 Answers 2

4

Are you referencing the jQuery script and a jQuery UI script that contains the datepicker plugin? Both script references should appear before your block of code.

The /// <reference path="jquery-1.5.1.js" /> lines are references for providing intellisense for JavaScript and should go in the relevant script i.e. in this case, this should reference the .vsdoc version of the jQuery script and go at the top of the jQuery script file.

In summary, the layout should be

<script type="text/javascript" src="jquery-1.5.1.js"></script> <script type="text/javascript" src="jquery-ui-1.8.11.js"></script> <script type="text/javascript"> $(document).ready(function () { $('.date').datepicker({dateFormat: "dd/mm/yy"});}); </script> 
Sign up to request clarification or add additional context in comments.

6 Comments

The error is unlikely to be in the jQuery script. The error may manifest as coming from jQuery, but it's more likely to be a problem with other code. What browser are you running it in (looks like IE)? Are you using any other scripts in the page?
@Russ..yeap, IE 7...and there other scripts in the page
Are you using jQuery validation? There was an issue with the rewrite of $.ajax (using the new $.Deferred object under the hood) and jQuery validation 1.7. Do you get the issue in other browsers?
@Russ...let me check the other browsers. I did figure out that it's a conflict. When I remove all the default js files that the .Net MVC3 app includes and then include:
@russ...the correct js files it works....see: stackoverflow.com/questions/7144736/…
|
-1

@Russ....thanks for the assistance. I found the issue. I had a Telerik scritp Registrar which was included in the _Layout.cshtml. That was causing the error. I imagine the Telerik js files are old. When I look at their documentation, their code is using MVC2 style

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.