且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在不使用“隐藏"的情况下关闭引导程序模态和“数据删除"

更新时间: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();
   }
});

演示

Demo2

请参见文档

Demo

Demo2

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.