Silent error in jQuery UI datepicker

I ran into a very strange problem.

I am creating a report package, and part of it uses the daterangepicker library to select a date range. However, during a function that creates everything, it just stops when it comes to calling creation $("#date-range-picker").daterangepicker(options). After some time, tracking calls through daterangepicker, jQuery and jQueryUI, I find that the call new Date()fails with an error RangeError: Maximum call stack size exceeded, and it seems that the code inside just keeps the error and still considers the Date object.

I tested creating a new date while the script was paused and it caused the same error. The same error occurs if the script fails. But not before the script starts.

UPDATE: I found a problem, it was a repeat of the daterangepicker script parameter.

+3
source share
1 answer

use dynamic identifiers for datepicker if you use datepicker more than once on one 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
source

Source: https://habr.com/ru/post/1792396/


All Articles