我想让它在你更改日期/约会时提醒"ok“。但是我会收到两个警报而不是一个?
我该如何解决这个问题呢?
代码如下:
$(document).ready(
function(){
$('#datePicking')
.daterangepicker({
arrows:true,
onChange: function(){
$('#Viewer')
alert('ok');
}
});
});
下面是一个有效的示例:http://jsfiddle.net/BU5PJ/2/
jquery 1.4.4,UI 1.8.5,+ daterangepicker from filamentgroup.com
发布于 2010-11-15 12:42:13
通过这里找到的文档的外观,http://www.filamentgroup.com/lab/date_range_picker_using_jquery_ui_16_and_jquery_ui_css_framework/
onChange:当日期输入发生变化时执行的回调函数(在选择范围时可能会发生两次)。
当我选择一个特定的日期时,我只得到了一个警告框。
发布于 2012-05-04 04:44:51
尝尝这个
$(document).ready(
function(){
$('#datePicking')
.daterangepicker({
arrows:true,
onClose : function(){
$('#Viewer')
alert('ok');
}
});
});
发布于 2017-07-06 16:24:21
在我的例子中,我使用的是daterangepicker和angular。我的目的是观察存储日期范围值的模型中的任何更改,并将其保存以便稍后进行AJAX调用。我面临着同样的问题,因为每当日期更改时,它都会触发两次事件,即使我选择了'Today':一次是具有startDate和endDate属性的对象,另一次是字符串。
It 可以作为优势加以利用。
$scope.$watch(
'rangeOfDate',
function (newValue) {
// Due to a known bug of open source library daterangepicker, the event is hit twice
//upon change. Once it is an object, and once it is a string. So, use appropriately.
var selectedDateRange = new Object();
if (typeof (newValue) == 'object') {
selectedDateRange.startDate = new Date(newValue.startDate).toLocaleDateString();
selectedDateRange.endDate = new Date(newValue.endDate).toLocaleDateString();
//Do as you wish with this custom object
}
else if (typeof (newValue) == 'string') {
alert("string");
}
},
false);
https://stackoverflow.com/questions/4184333
复制相似问题