1

我希望它在您更改/约会时提醒“好的”。但是我收到两个警报而不是一个?

我怎样才能解决这个问题?

这是代码:

$(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,+来自 filamentgroup.com 的 daterangepicker

4

3 回答 3

2

根据此处找到的文档的外观http://www.filamentgroup.com/lab/date_range_picker_using_jquery_ui_16_and_jquery_ui_css_framework/

onChange:函数,每当日期输入更改时执行的回调(在范围选择上可能发生两次)。

当我选择一个特定的日期时,我只得到一个警报框。

于 2010-11-15T12:42:13.367 回答
0

尝试这个

$(document).ready(
 function(){
 $('#datePicking')
   .daterangepicker({
   arrows:true,
   onClose : function(){
       $('#Viewer')
       alert('ok');
    }
   }); 
});
于 2012-05-04T04:44:50.703 回答
0

就我而言,我正在使用带角度的 daterangepicker。我的目的是观察存储日期范围值的模型中的任何更改,并将其保存以供稍后进行 AJAX 调用。我面临同样的问题,因为即使我选择“今天”,只要更改日期,它就会触发两次事件:一次是具有 startDate 和 endDate 属性的对象,另一次是字符串

可以作为一种优势加以利用。

    $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);
于 2017-07-06T16:24:21.160 回答