$(document).ready(function() {
// Support for AJAX loaded modal window.
// Focuses on first input textbox after it loads the window.
$('[data-toggle="modal"]').click(function(e) {
e.preventDefault();
var href = $(this).attr('href');
if (href.indexOf('#') == 0) {
$(href).modal('open');
} else {
$.get(href, function(data) {
$('<div class="modal" >' + data + '</div>').modal();
}).success(function() { $('input:text:visible:first').focus(); });
}
});
});
$(document).ready(function() {
// This is what triggers for a modal link in Datatables.
// Note I put an extra class in my links, class='mymodallink'
// in the <a> tag. Note that the e.preventDefault() is
// commented out. I'm not sure why it wouldn't work
// with it...
$("#example .mymodallink").live("click", function() {
//e.preventDefault();
var href = $(this).attr('href');
if (href.indexOf('#') == 0) {
$(href).modal('open');
} else {
$.get(href, function(data) {
$('<div class="modal" >' + data + '</div>').modal();
}).success(function() { $('input:text:visible:first').focus(); });
}
});
// This is the normal way of using an AJAX modal based on
// https://gist.github.com/1688900
// except I changed the data-toggle attribute to 'normalmodal'
// because I didn't want the datatables links to sometimes
// trigger two modals.
$('[data-toggle="normalmodal"]').click(function(e) {
e.preventDefault();
var href = $(this).attr('href');
if (href.indexOf('#') == 0) {
$(href).modal('open');
} else {
$.get(href, function(data) {
$('<div class="modal" >' + data + '</div>').modal();
}).success(function() { $('input:text:visible:first').focus(); });
}
});
});
It looks like you're new here. If you want to get involved, click one of these buttons!
Get useful and friendly help straight from the source.