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 id="modal-container" class="modal fade hidden-print" tabindex="-1" role="dialog"> | |
<div class="modal-dialog"> | |
<div class="modal-content"> | |
</div> | |
</div> | |
</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
@* Create a link that calls the controller method that returns the partial view*@ | |
@Html.ActionLink("Open Modal", "ModalAction", "Home", new { Id = id }, new | |
{ | |
@* Needed to link to the html of the modal*@ | |
data_target = "#modal-container", | |
@* Tells the bootstrap javascript to do its thing*@ | |
data_toggle = "modal" | |
}) |
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"> | |
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |
<span aria-hidden="true">×</span> | |
</button> | |
<h4 class="modal-title">Basic Modal</h4> | |
</div> | |
<div class="modal-body"> | |
<div class="form-horizontal"> | |
Hello World! | |
@ViewBag.Id |
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
$(function () { | |
// when the modal is closed | |
$('#modal-container').on('hidden.bs.modal', function () { | |
// remove the bs.modal data attribute from it | |
$(this).removeData('bs.modal'); | |
// and empty the modal-content element | |
$('#modal-container .modal-content').empty(); | |
}); | |
}); |
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
// boostrap 4 load modal example from docs | |
$('#modal-container').on('show.bs.modal', function (event) { | |
var button = $(event.relatedTarget); // Button that triggered the modal | |
var url = button.attr("href"); | |
var modal = $(this); | |
// note that this will replace the content of modal-content ever time the modal is opened | |
modal.find('.modal-content').load(url); | |
}); |