更新时间:2023-09-12 16:58:10
您可以使用本身使用data-dismiss
属性的自动模式关闭行为,也可以使用手动模式打开(例如,我猜您当前正在执行),订阅hide
事件并在事件上使用preventDefault
.
You can do it with auto modal closing behavior which uses the data-dismiss
attribute itself or with the manual modal opening (as i guess you are doing currently) , by subscribing to hide
event and use preventDefault
on the event.
$('yourmodalselector').on('hide',function(e){
if(yourConditionNotToCloseMet){
e.preventDefault();
}
});
请参见文档
See Documentation
隐藏事件事件是在调用hide实例方法后立即触发的,该方法将以枯燥的方式被调用,这是防止模式关闭的***位置.
hide event event is fired immediately when the hide instance method has been called, which gets called wither way and this is the best place to prevent the modal from closing.