-
-
Save kneidels/3492993 to your computer and use it in GitHub Desktop.
Dynamic (AJAX) loaded Bootstrap Modal (Bootstrap 2.0) : Fix for removing the response Modal content
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
$('[data-toggle="modal"].ajax').click(function(e) { | |
e.preventDefault(); | |
var url = $(this).attr('href'); | |
var target = $(this).data('target'); | |
if (url.indexOf('#') == 0) { | |
$(target).modal('open'); | |
} else { | |
$.get(url, function(data) { | |
$(target).html(data); | |
$(target).modal(); | |
}).success(function() { $('input:text:visible:first').focus(); }); | |
} | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="/url/to//modal_window.htm" data-toggle="modal" class="ajax" data-target="response_modal">link</a> | |
<div id="response_modal" class="modal hide fade"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="modal-header"> | |
<a class="close" data-dismiss="modal">×</a> | |
<h3>Modal header 2</h3> | |
</div> | |
<div class="modal-body"> | |
<p>One body...</p> | |
</div> | |
<div class="modal-footer"> | |
<a class="btn btn-primary">Save Changes</a> | |
<a class="btn" data-dismiss="modal">Close</a> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment