uxsolutions / bootstrap-datepicker

A datepicker for twitter bootstrap (@twbs)
Apache License 2.0
12.67k stars 6.06k forks source link

inifite recursion due to change event when setting endDate and startDate #1669

Open zawaideh opened 9 years ago

zawaideh commented 9 years ago

Hi,

There is a problem in the update function when setting endDate and startDate (https://github.com/eternicode/bootstrap-datepicker/blob/master/js/bootstrap-datepicker.js#L806). this.element.change() is being called even if the date hasn't changed. I have a function that listens to changes on two date inputs and sets the startDate and endDate depending on their value. This line causes this function to be impossible since it triggers a change, which triggers setting startDate and endDate which triggers a change.. etc.

zawaideh commented 9 years ago

I believe this.element.change() should only be called if the dates changed.

acrobat commented 9 years ago

Can you provide a jsfiddle example to display the problem?

zawaideh commented 8 years ago

Here is an example that reproduces it: https://jsfiddle.net/d33dh3ng/1/

On firefox you will see 'Too much recursion' in the console output.