开发者

Silent Error in jQuery UI datepicker

I have encountered a very strange problem.

I am building a reporting package and part of it uses the daterangepicker library to, well, pick a date range. However, during the function that creates everything, it just stops once it gets to the creation call $("#date-range-picker").daterangepicker(options). After some time tracing the calls through daterangepicker, jQuery, and jQueryUI, I discover that a call to new Date() is failing with the error RangeError: Maximum call stack size exceeded, and it seems that the code inside just stores the error and still thinks its a Date object.

I tested creating a new date while the script was paused there and it caused the same error. The same error happens once the script has fails. But not开发者_开发百科 before the script starts.

UPDATE: I found the problem, it was a repetition of the daterangepicker script include.


use dynamic IDs for datepicker if you use datepicker more than one time at same page.

$(".any_class").live({

     focus: function(){ 
         var id = $(this).attr("id");
        $( "#"+ id ).datepicker({
        numberOfMonths: 1, 
        yearRange: '1960:2020',
        dateFormat: 'dd-mm-yy',
        showButtonPanel: false,
        changeMonth: true,
        changeYear: true,
        onClose: function(){ /*anything on close*/ }

        });
        }  
    });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜