我需要在模式关闭时调用一个函数。我的代码如下,
function openModal(divName) {
$("#"+divName+"Modal").modal({
overlayClose: false,
closeHTML: "<a href='#' title='Close' class='modal-close'>X</a>",
onShow: function (dialog) {
$('#simplemodal-container').css({ 'width': 'auto', 'height': 'auto', 'padding-bottom': '1000px' });
var tmpW = $('#simplemodal-container').width() / 2
var tmpH = $('#simplemodal-container').height() / 2
$('#simplemodal-container').css({ 'margin-left': tmpW * -1, 'margin-top': tmpH * -1 });
},
close:onClose,
onClose: ModalClose(),
opacity: 50,
persist: true
});
}
我尝试了以下两种方法来调用函数,但均不起作用
第一方式
function onClose() {
alert('called');
}
第二方式
$('.resetbutton').click(function () {
alert('called');
}
如果用户定义了函数,则在ModalClose()内调用您想要的另一个函数
从引导程序文档中,您可以在关闭模式Javascript.Bootstrap时调用javascript事件>
$('#myModal').on('hide.bs.modal', function (e) { // do the closing function... });
对于剑道图书馆,您可以关闭但不带“()”,这将在函数中传递事件“ e”
关闭:onClose,
dialog.kendoDialog({
width: "400px",
title: "Software Update",
closable: true,
modal: false,
content: "<p>A new version of <strong>Kendo UI</strong> is available. Would you like to download and install it now?<p>",
actions: [
{ text: 'Close', action: onCancel },
{ text: 'OK', primary: true, action: onOK }
],
initOpen: onInitOpen,
open: onOpen,
close: onClose,
show: onShow,
hide: onHide
});
function onClose(e) {
show.fadeIn();
kendoConsole.log("event :: close");
}