Bootstrap datepicker toggle disable

user3751955 picture user3751955 · Jul 16, 2014 · Viewed 7.3k times · Source

I am using bootstrap-datepicker and getting an issue.

When I click a day, it works well,but when I click the same day again. The selection gets cancelled

The boostrap datepicker demo works well.

I had found the example for bootstrap date picker from the above link.

Answer

AntonK picture AntonK · Oct 15, 2014

It's a known issue. Here is a workaround for this issue.

https://github.com/eternicode/bootstrap-datepicker/issues/816

jsfiddle the issue: http://jsfiddle.net/antonkruger/fpgseobz/

Once I've tried it, I'll post an update.

Update: Yes it works.

In the defaults @ line 1394, add a new option, allowDeselection

var defaults = $.fn.datepicker.defaults = {
    allowDeselection: false,
    ...
};

In the _toggle_multidate function @ line 1015, modify the "else if (ix !== -1)" statement to:

else if (ix !== -1 && this.o.allowDeselection){
   this.dates.remove(ix);
}