Bootstrap datepicker toggle disable

∥☆過路亽.° 提交于 2019-12-06 12:01:57

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);
}

I came across this issue myself so if you still need this. trick is to store the current date in a variable each time a new date is created. If the new date is undefined (empty) update date with the temporary variable. I know its a dirty solution, but hey atleast its working.

I wrote a little fiddle enter code herehttp://jsfiddle.net/d86msex1/

Goodluck!

There's now an official way to accomplish this:

$element.datepicker('remove');

source: http://bootstrap-datepicker.readthedocs.org/en/release/methods.html#remove

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!