English 中文(简体)
j Query Dayrangepicker: 两次执行警戒?
原标题:jQuery daterangepicker: executes alert twice?

当你改变/改变某一日期时,我想提醒大家注意“ok”。 但是,这只是两个警示而不是一个警报?

如何解决这一问题?

这部法典:

$(document).ready(function(){
       $( #datePicking ).daterangepicker({
           arrows:true,
           onChange: function(){                  
               alert( ok );
           }
       }); 
});

我正在使用jquery 1.3.2和ID 1.7.2。

最佳回答
问题回答

最好在Close而不是在Change使用

 $(document).ready(function(){
    $( #datePicking ).daterangepicker({
       arrows:true,
       onClose : function(){                  
           alert( ok );
       }
   }); 
});

这样做可能有助于

In my case, I am using daterangepicker with angular. My purpose is to watch any change in the model that stores the date range value and save it for an AJAX call later. I face the same issue as it hits the event twice whenever the date is change even if it is only Today : Once it is object with startDate and endDate properties, and the other time it is a string.

可以利用这一优势。

 $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);




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签