我正在使用以下代码打印徽章信息,打印后模态框未关闭
$("#printCnfWithoutLoginForm").formValidation({
framework: 'bootstrap',
excluded: ':disabled',
icon: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
emailAdressWLogin: {
verbose: false,
trigger: 'blur',
validators: {
notEmpty: {
message: 'Email is Required'
},
regexp: {
regexp: /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9]{2,})+\.)+([a-zA-Z0-9]{2,4})+$/,
message: 'Please enter valid email address'
},
remote: {
type: 'POST',
url: '<?php echo get_site_url() ?>/wp-content/themes/mesocolumn/eventDetailsAjax.php/',
message: 'Sorry, You have not register for this event',
data: {
eventidWLogin: function () {
return $('#eventidWLogin').val()
},
eventtypeWLogin: function () {
return $('#eventtypeWLogin').val()
}
},
}
}
}
}
}).on('success.form.fv', function (e) {
// Prevent form submission
e.preventDefault();
var $form = $(e.target),
fv = $form.data('formValidation');
var data = $form.serialize();
// Use Ajax to submit form data
$.ajax({
url: $form.attr('action'),
type: 'POST',
data: data,
success: function (data) {
var printWindow = window.open('', '', 'height=400,width=800');
var is_chrome = Boolean(printWindow.chrome);
printWindow.document.write(data);
if (is_chrome) {
setTimeout(function () { // wait until all resources loaded
printWindow.document.close(); // necessary for IE >= 10
printWindow.focus(); // necessary for IE >= 10
printWindow.print(); // change window to winPrint
printWindow.close(); // change window to winPrint
}, 400);
} else {
printWindow.document.close(); // necessary for IE >= 10
printWindow.focus(); // necessary for IE >= 10
printWindow.print();
printWindow.close();
}
}
});
$('#autoUpdate2').modal('hide');
});
答案 0 :(得分:2)
您可以手动调用remove()
方法将模式关闭为
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();