Why does bootstrap-datepicker trigger 'show.bs.modal' when it is displayed?

自闭症网瘾萝莉.ら 提交于 2019-12-02 21:07:48

This is a bug in date picker library. You can track it on github here. There is workaround given there by @kroeder

$("#my-datepicker").datepicker().on('show.bs.modal', function(event) {     // prevent datepicker from firing bootstrap modal "show.bs.modal"     event.stopPropagation();  }); 

Use this

$(date-picker-selector).on("show", function(e){      e.preventDefault();      e.stopPropagation(); }).on("hide", function(e){      e.preventDefault();      e.stopPropagation(); }); 

Try this:

modal.on('show.bs.modal', function(e) {     if (e.namespace === 'bs.modal') {         // Your code here     } }); 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!