繁体   English   中英

引导(2)IE7 / 8中的多个日期选择器

[英]Bootstrap (2) multiple datepickers in IE7/8

我在一个页面上的三个表格中分布了三个日期字段。 每个日期字段都使用引导日期选择器。 每个字段都是出生日期,因此,只要更改任何三个字段,这三个字段都会更新。

所有这些都可以在FF,Chrome等中完美运行。

但是,当您使用IE8 / 7时,日期选择器而不是清除输入字段,而是以逗号分隔的列表样式连接新值。 我尝试使用multidate:false(即使这是默认设置),但没有效果。

有任何想法吗 ?

这是小提琴: http : //jsfiddle.net/moonspace/xaH2n/

这是代码:

// Set default value
$("#oneDate").val("01/01/1990");
$("#twoDate").val("01/01/1990");
$("#threeDate").val("01/01/1990");

var defaultDate = "25/12/1990";

// Set up datepicker
$("#oneDate, #twoDate, #threeDate").datepicker({
    format: "dd/mm/yyyy",
    startDate: "-89y",
    endDate: "-17y",
    startView: 2,
    autoclose: true,
    orientation: "top left"
}).on("changeDate", function() {
    var newDoB = $(this).val();

    $("#oneDate").datepicker("update", newDoB);
    $("#twoDate").datepicker("update", newDoB);
    $("#threeDate").datepicker("update", newDoB);
});

// Reset value
$("button").on("click", function() {
    $("#oneDate").datepicker("update", defaultDate);
    $("#twoDate").datepicker("update", defaultDate);
    $("#threeDate").datepicker("update", defaultDate);
}); 

提示: 我们发现,要在IE中运行小提琴,请使用chrome / FF登录您的帐户并打开小提琴。 然后在IE中转到http://jsfiddle.net/draft并登录,您的小提琴将出现。

问题实际上出在Internet Explorer上。

Internet Explorer中的拼接功能实际上需要一个额外的参数来实现Firefox和Chrome的功能。 IE <= 8 .splice()无法正常工作

如果您查看bootstrap-datepicker.js代码,则其中包含

this.splice(0);

因此,您的解决方案是使用更新的修订(尚未发布:/)来获取bootstrap-datepicker的主分支( https://github.com/eternicode/bootstrap-datepicker/blob/master/js/bootstrap-datepicker) .js

要么

通过JavaScript http://www.to-string.com/2012/05/29/fixing-splice-in-older-versions-of-internet-explorer- '修复'splice(0)函数在Internet Explorer中的工作方式8岁以上/

暂无
暂无

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

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