3

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.

3
  • 1
    drum-roll! a stackoverflow, to bad the question already has 5 tags.. Commented Feb 16, 2011 at 2:48
  • Is there any other script on that page that may be causing the problem? Commented Feb 16, 2011 at 2:49
  • Hmm, doesn't seem that I can close it without deleting it. Anyway, I found the problem, it was a duplication of the daterangepicker script. Though the script error didn't exactly lead me to that conclusion.
    – Aatch
    Commented Feb 16, 2011 at 3:40

1 Answer 1

0

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*/ }

        });
        }  
    });

Not the answer you're looking for? Browse other questions tagged or ask your own question.