Skip to content

Instantly share code, notes, and snippets.

View AlexanderLindsay's full-sized avatar

Alexander Lindsay AlexanderLindsay

View GitHub Profile
@AlexanderLindsay
AlexanderLindsay / bootstrap-modal-definition.html
Created April 24, 2016 00:26
basic bootstrap modal definition
<div id="modal-container" class="modal fade hidden-print" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
</div>
</div>
</div>
@AlexanderLindsay
AlexanderLindsay / razor-bootstrap-modal-link.cshtml
Last active April 24, 2016 01:15
A razor link that opens a bootstrap modal
@AlexanderLindsay
AlexanderLindsay / bootstrap-modal-content.html
Created April 24, 2016 02:36
The content of a bootstrap modal
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">Basic Modal</h4>
</div>
<div class="modal-body">
<div class="form-horizontal">
Hello World!
@ViewBag.Id
@AlexanderLindsay
AlexanderLindsay / bootstrap-modal-clear.js
Created April 24, 2016 02:57
javascript to clear a bootstrap modal on close
$(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();
});
});
@AlexanderLindsay
AlexanderLindsay / bootstrap-v4-modal-load.js
Created April 24, 2016 03:04
javascript to load a bootstrap modal content from an anchor tag
// 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);
});