简体   繁体   English

jQuery日期选择器在ASP.Net MVC4中无法正常工作

[英]jQuery date picker is not working properly in ASP.Net MVC4

I need to implement jQuery date picker in my project. 我需要在我的项目中实现jQuery日期选择器。 This is my script: 这是我的脚本:

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

I added these links in my HTML: 我在HTML中添加了这些链接:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>

<label style="padding-left: 5px;">Date</label><input type="text" id="datepicker" />

But I can't get the dropdown window to show with that code. 但我无法通过该代码显示下拉窗口。 How can I solve this problem? 我怎么解决这个问题? When I looked into the view source of the page, there are some extra jquery scripts for the function like: 当我查看页面的视图源时,该函数有一些额外的jquery脚本,如:

    <link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
    <link href="../../Content/themes/base/jquery-ui-1.9.2.css" rel="stylesheet" type="text/css" />
    <link href="/Scripts/jtable/themes/standard/jtable_empty.css" rel="stylesheet" type="text/css" />
    <link href="../../Content/application.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.8.3.js" type="text/javascript"></script>
    <script src="/Scripts/jquery.unobtrusive-ajax.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-ui-1.9.2.js" type="text/javascript"></script>
    <script src="/Scripts/jtable/jquery.jtable.js" type="text/javascript"></script>
    <script src="../../Scripts/knockout-2.1.0.js" type="text/javascript"></script>
    <link href="/Scripts/jtable/themes/standard/jtable_empty.css" rel="stylesheet" type="text/css" />
    <link href="/Content/themes/base/jquery-ui-1.9.2.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/jtable/jquery.jtable.js" type="text/javascript"></script>
    <script src="/Scripts/jquery.cookie.js" type="text/javascript"></script>
    <script src="/Scripts/modernizr-1.7.min.js" type="text/javascript"></script>
    <script src="/Scripts/knockout-2.2.0.js" type="text/javascript"></script>
    <script src="/Scripts/advancedSearch/AdvancedSearch.js" type="text/javascript"></script>
    <script src="/Scripts/advancedSearch/jquery.validationEngine.js" type="text/javascript"></script>
    <script src="/Scripts/advancedSearch/jquery.validationEngine-en.js" type="text/javascript"></script>
    <link href="/Scripts/advancedSearch/validationEngine.jquery.css" rel="stylesheet" type="text/css" />

Try to use noConflict() to avoid the conflicts. 尝试使用noConflict()来避免冲突。

Example: 例:

<script type="text/javascript" src="other_lib.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
  $.noConflict();
  // Code that uses other library's $ can follow here.
</script>

see here 看这里

you can do following 你可以做到以下

Call your jQuery related script first 首先调用jQuery相关脚本

<script type="text/jscript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script type="text/jscript" src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>

then 然后

var jQueryVariable = jQuery.noConflict(true); var jQueryVariable = jQuery.noConflict(true);

now use the jQueryVariable to call wherever you want to call the jQuery for date picker 现在使用jQueryVariable调用你想要调用日期选择器的jQuery的任何地方

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM