Twitter bootstrap - open modal over an already opened modal

Deadly 提交于 2019-12-03 06:28:51

问题


Here's my scenario: I'm opening a modal window with some record details, and I've a "Delete" button. When user clicks on this button, I need to show a "confirmation" modal above/over the existing modal (asking "are you sure?"), but when this confirmation modal is showed, it doesn't block the "details" first modal (behind).

Does anyone know how can I do it?

Thanks!


回答1:


It's quite easy to do it. Links in your already opened modal have to look like this:

<a href="NEW URL" data-dismiss="modal" data-toggle="modal" data-target="#newModal">Anchor text</a>

data-dismiss="modal" -> will close that modal = that is the trick!!!!
data-toggle="modal" -> will open new dialog

Enjoy!




回答2:


All you need to do is place the markup for the confirmation modal lower down in the code than the details modal.




回答3:


Simply hide #modal and show #modal2 when click on #deleteButton

$("#deleteButton").click(function() {
$('#myModal').modal('hide')
$('#myModal2').modal('show')    
});

Here's a working example: http://jsfiddle.net/baptme/nuUzN/14/




回答4:


How about adding a z-index to the second modal? Like:

<div class="modal fade" style="z-index:1050">modal content here...</div>

If the value 1050 doesn't work try a higher number aka 99999.



来源:https://stackoverflow.com/questions/10274710/twitter-bootstrap-open-modal-over-an-already-opened-modal

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