The solution to your problem is to do the z-index for each of the modes:
Javascript:
$(document).ready(function () {
$('.modal')
.on({
'show.bs.modal': function() {
var idx = $('.modal:visible').length;
$(this).css('z-index', 1040 + (10 * idx));
var url = $(this).find('[data-url]').data('url');
if (url != undefined && url != '') {
var id = $(this).attr('id');
$('#'+id+' .modal-body').load(url);
}
},
'shown.bs.modal': function() {
var idx = ($('.modal:visible').length) - 1; // raise backdrop after animation.
$('.modal-backdrop').not('.stacked')
.css('z-index', 1039 + (10 * idx))
.addClass('stacked');
},
'hidden.bs.modal': function() {
if ($('.modal:visible').length > 0) {
// restore the modal-open class to the body element, so that scrolling works
// properly after de-stacking a modal.
setTimeout(function() {
$(document.body).addClass('modal-open');
}, 0);
}
}
});
});
HTML:
1) button:
<a data-toggle="modal" data-url="ver_detalhes.php?cod=<?php echo $codigo;?>" href="#myModal" class="btn btn-primary">Visualizar</a>
2) modal:
<div class="modal fade" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Detalhes</h4>
</div>
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-body"><!--aqui fará um 'load' do conteúdo da sua URL... --></div>
</div>
</div>
<div class="modal-footer"> <a href="#" data-dismiss="modal" class="btn btn-default">Fechar</a>
</div>
</div>
</div>
</div>