【问题标题】:datepicker ui not working correctly on edit pagedatepicker ui 在编辑页面上无法正常工作
【发布时间】:2014-11-24 10:19:50
【问题描述】:

我使用 datepicker ui 来选择开始日期和结束日期。它在创建页面上正常工作。但在编辑页面上不能正常工作。当我在编辑页面中单击开始日期时,结束日期自动变空。我正在使用以下 javascript。 css和js文件:

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/cupertino/jquery-ui.css">
        <script src="//code.jquery.com/jquery-1.10.2.js"></script>
        <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>

Javascript:

$(document).ready(function () {
    $("#from").datepicker({
        dateFormat: 'dd/mm/yy',
        changeMonth: true,
        changeYear: true,
        numberOfMonths: 1,
        onClose: function (selectedDate) {
            $("#to").datepicker("option", "minDate", selectedDate);
        }
    });
    $("#to").datepicker({
        dateFormat: 'dd/mm/yy',
        changeMonth: true,
        changeYear: true,
        numberOfMonths: 1,
        onClose: function (selectedDate) {
            $("#from").datepicker("option", "maxDate", selectedDate);
        }
    });
});

我的看法:

<p>Start Date: <input type="text" id="from"></p>
<p>End Date: <input type="text" id="to"></p>

查看错误截图: http://i.imgur.com/vz0DbGe.png 当我单击开始日期时,它默认突出显示并仅显示当前日期。

http://i.imgur.com/vz0DbGe.png 选择开始日期后,自动结束日期变为空..并且默认显示2020年..

【问题讨论】:

  • 您检查过selectedDate 在活动中的内容吗?
  • 如何查看活动中的 selectedDate ? @artm
  • console.log(selectedDate) 并检查您的控制台。
  • console.log 为空.. @artm

标签: javascript jquery jquery-ui date datepicker


【解决方案1】:

进口 jquery-1.10.2.js jquery-ui.js jquery-ui.css 你的代码将开始运行

【讨论】:

  • 我使用上面的css和js文件。
猜你喜欢
  • 1970-01-01
  • 2015-06-28
  • 1970-01-01
  • 2021-09-26
  • 1970-01-01
  • 2021-06-16
  • 1970-01-01
  • 2014-12-13
相关资源
最近更新 更多