Skip to content

Instantly share code, notes, and snippets.

@calevano calevano/openModal.js
Last active Jan 30, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.