bootstrap modal safeshow
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/2.3.2/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/2.3.2/js/bootstrap.min.js"></script>
<button id="b2">open</button>
<div id="modal1" class="modal">
<div>
hello world
<button id="b1">reopen</button>
<button id="close">close</button>
</div>
</div>
JavaScript
$.fn.modal.Constructor.prototype.safeShow = function() {
var that = this;
if (this.$backdrop) {
this.$element.one('hidden',
function(){that.show()});
} else {
this.show();
}
}
$("#modal1").modal('safeShow');