Skip to content

Instantly share code, notes, and snippets.

@calevano
Last active January 30, 2018 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calevano/e2153a25aa642ff10a5f8dfb7bd3fc41 to your computer and use it in GitHub Desktop.
Save calevano/e2153a25aa642ff10a5f8dfb7bd3fc41 to your computer and use it in GitHub Desktop.
Create simple openModal
#In view
<a href="[_route_]"
class="btn btn btn-success btn-circle btn-xs zmdi zmdi-edit"
data-toggle='modal'
data-target="#openModal"
data-tamanio='lg'>
</a>
#OpenModal
$(document).on('click', '[data-target=#openModal]', function (e) {
e.preventDefault();
var target = $(this).attr("href");
var small = $(this).data('tamanio');
var category = (typeof $(this).data('categoria') === "undefined") ? "" : $(this).data('categoria');
if (target.indexOf('#') === 0) {
$(target).modal('open');
} else {
$.get(target, function (data) {
$('<div class="modal fade mimodalpe ' + category + '" data-backdrop="static" data-keyboard="false"><div class="modal-dialog modal-darkorange modal-' + small + '"><div class="modal-content">' + data + '</div></div></div>').modal();
}).success(function () {
});
}
});
#closeModal
$(document).on('click', '.btnDeleteModal', function () {
setTimeout(function () {
$('.mimodalpe').remove();
}, 500);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment