使用.js文件时,日期选择器不起作用

时间:2014-06-14 10:27:59

标签: jquery asp.net-mvc-3

我在.net MVC5中使用js文件我在.js文件中编写了datepicker代码Installation.js我的datepicker代码无效。

(function() {

    Installation.func.initailElement = function () {
        $('#datepicker1').datepicker({
            beforeShowDay: function (dt) {

                var noWeekend = $.datepicker.noWeekends(dt);
                var bDisable = noWeekend[0] ? arrDisabledDates[dt] : noWeekend

                if (bDisable)
                return [false, '', ''];
                else
                return [true, '', ''];
            }, 
            minDate: Installation.func.customDate(), 
            showOn: "both", 
            buttonImage: "~/assets/css/theme/flush-datepicker.gif", 
            buttonImageOnly: true
        });
        Installation.func.bindEvents();

    };

})();

CODE对于部分视图,我在部分视图中包含了必需的.js文件。

<body>

 <div class="fui-form-body">
 <input type="text" id="datepicker" name="datepicker" class="fui-input-width-2">
 </div> 
 </body>

1 个答案:

答案 0 :(得分:2)

使用

$('#datepicker').datepicker(...)

而不是

$('#datepicker1').datepicker(...)
  1. 您的<input>元素有Id - datepicker。

  2. 并在脚本标记中包含对jQuery UI文件上方的jQuery文件的引用。