jqgrid信息对话框功能onClose [英] jqgrid info dialog function onClose
问题描述
我正在显示带有info_dialog的服务器错误消息. 当info_dialog ist关闭时,我想触发一个函数.我试图通过单击鼠标来完成此操作,但是只有在对话框关闭后才会触发
i am showing the server error message with an info_dialog. I would like to fire a function, when the info_dialog ist getting closed. I have tried to do it with a mouse click, but it only fires after the dialog is already closed
第一次单击:对话框关闭,但未触发警报
first mouseclick: dialog closes, but alert is not fired
第二秒以及随后的每一次鼠标单击:都会触发警报.
second and every following mouseclick: alert is fired.
我正在使用celledit. 任何有想法的人,当对话框关闭时,我怎么能触发一个函数? 感谢您的帮助.
I am using celledit. Anyone with an idea how i can fire a function, when the dialog ist getting closed? Thanks for your help.
errorCell: function(serverresponse, status) {
$.jgrid.info_dialog(
$.jgrid.errors.errcap,
serverresponse.responseText,
$.jgrid.edit.bClose,
{ zIndex: 1500}
);
$(document).click(function() {
alert( "Handler for .click() called." );
});
}
推荐答案
方法$.jgrid.info_dialog
支持onClose
回调,该回调将在关闭时调用.回调的返回值通知是否允许关闭.只需尝试代码
The method $.jgrid.info_dialog
supports onClose
callback which will be called on closing. The return value from the callback informs whether the closing is permitted. Just try the code
$.jgrid.info_dialog(
$.jgrid.errors.errcap,
serverresponse.responseText,
$.jgrid.edit.bClose,
{
zIndex: 1500,
onClose: function () {
alert("inside onClose");
return true; // allow closing
}
}
);
已更新:要在对话框的外部上单击鼠标以捕获$.jgrid.info_dialog
的关闭,必须执行更复杂的操作.
UPDATED: To catch closing of $.jgrid.info_dialog
in case of clicking with the mouse outside of the dialog one have to do more complex trick.
var orgViewModal = $.jgrid.viewModal;
$.extend($.jgrid,{
viewModal: function (selector, options) {
if (options.onHide) {
options.orgOnHide = options.onHide;
options.onHide = function (h) {
alert("inside onHide");
return options.orgOnHide.call(this, h);
}
}
return orgViewModal.call (this, selector, options);
}
});
$.jgrid.info_dialog($.jgrid.errors.errcap, "Test message",$.jgrid.edit.bClose, {
zIndex: 1500,
onClose: function () {
alert("inside onClose");
return true; // allow closing
}
});
在代码的第一部分中,我使用$.jgrid.viewModal
方法的子类化"(就像我在答案中使用的,此和其他).因此,除了一个例外,我将所有调用转发到原始的$.jgrid.viewModal
方法.如果使用onHide
回调参数调用$.jgrid.viewModal
方法,我将转至原始$.jgrid.viewModal
方法修改的回调实现.它允许捕获对话框的关闭.
In the first part of the code I use "subclassing" of $.jgrid.viewModal
method (like I used in the answer, this one and some other). So I forward all calls to original $.jgrid.viewModal
method with one exception. If $.jgrid.viewModal
method are called with onHide
callback parameter I forward to original $.jgrid.viewModal
method modified implementation of the callback. It allows to catch closing of the dialog.
更新2 :该演示实时显示该方法.
(替代子类化)您也可以修改行
Alternatively (instead of subclassing) you can just modify the lines
onHide: function(h) {
h.w.hide().remove();
if(h.o) { h.o.remove(); }
},
jquery.jqGrid.src.js
中info_dialog
的
.如果定义了该选项,则只需插入mopt.onClose
的其他调用.可能应该包含附加回调onClosed
,因为onClose
可以拒绝关闭,但是在onHide
内部调用的新回调不能这样做.
of info_dialog
in jquery.jqGrid.src.js
. You need just insert additional call of mopt.onClose
if the option defined. Probably one should include additional callback onClosed
because onClose
can deny closing, but new callback called inside of onHide
can't do this.
这篇关于jqgrid信息对话框功能onClose的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!