0

I have an asp.net mvc application in Visual Studio 2013. I have a problem when using jQuery UI tools. I have the following scripts in my _Layout.cshtml:

@Scripts.Render("~/bundles/modernizr")

<script src="@Url.Content("~/Scripts/1.7.2.jquery.min.js")" type="text/javascript"></script>

<script src="@Url.Content("~/Scripts/jquery-2.1.0.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-2.1.0.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-ui-1.10.4.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.10.4.min.js")" type="text/javascript"></script>

 @Scripts.Render("~/bundles/jquery")
 @Scripts.Render("~/bundles/bootstrap")
 @RenderSection("scripts", required: false)

when I try to use datepicker() :

 <script type="text/javascript">
    jQuery(document).ready(function () {
        $('.rDate').datepicker();
    });
</script>

 @Html.TextBox("date", new DateTime(2014, 1, 1), new { @class=".rDate"})

I get the the error: JavaScript runtime error: Object doesn't support property or method 'datepicker'

I'd appreciate any help.

3
  • I think jquery UI js file not included in the page. But why you are referring minified & uncompressed version. Use either one Commented Apr 4, 2014 at 7:13
  • See the viewsource of the page in firefox and check how many jQuery & jQuery UI files referenced. It looks like you are referring multiple times. Also click on each link and see whether the file content is loaded or 404 Commented Apr 4, 2014 at 7:15
  • @MuraliMurugesan, I checked the links, they work. I'd be so grateful if you could provide a demo project where datepicker works.
    – Gyuzal
    Commented Apr 4, 2014 at 8:27

1 Answer 1

0
@Scripts.Render("~/bundles/modernizr")

<script src="@Url.Content("~/Scripts/jquery-2.1.0.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-ui-1.10.4.min.js")" type="text/javascript"></script>

 @Scripts.Render("~/bundles/jquery")
 @Scripts.Render("~/bundles/bootstrap")
 @RenderSection("scripts", required: false)

Use minified version of Jquery and Jquery UI and remove repeated script references.

Demo:

http://jsfiddle.net/8Nyy7/

3
  • it didn't help. And Js files links work. Could you please provide any sample project, where datepicker works?
    – Gyuzal
    Commented Apr 4, 2014 at 8:25
  • @GyuzalRakhmayeva, I have added demo in my answer. Please check.
    – RGS
    Commented Apr 4, 2014 at 8:38
  • Thanks for the demo. And I found the reason, I needed to remove @Scripts.Render("~/bundles/jquery")
    – Gyuzal
    Commented Apr 4, 2014 at 8:51

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.