简体   繁体   English

JQGRID-JQMODAL:单击覆盖时禁用关闭模式

[英]JQGRID - JQMODAL: Disable close modal when click on overlay

I am trying to disable close on click when clicking the overlay behind the edit form Modal that opens when I edit a row, but I dont know how I have to do it. 我试图在单击编辑表单模态后面的覆盖层时禁用单击关闭功能,该模态在我编辑行时打开,但是我不知道该怎么做。 I were trying something like: 我正在尝试类似的东西:

editOptions: {
    url: 'foo/edit.html',
    mtype: 'PUT',

    //some other options
    closeAfterEdit: true,
    reloadAfterSubmit: true,
    onClose: function() {
        alert('Hi ^_^');
    }
}

But this only triggers if I click at 'X' button. 但这仅在我单击'X'按钮时触发。 If I click at overlay (out of modal) it closes the modal and that alert never triggers. 如果单击覆盖(模式之外),它将关闭模式,并且该警报永远不会触发。 What I want is to disable that closing function when I click out of modal or remove that overlay. 我想要的是在我退出模态或删除该叠加层时禁用该关闭功能。

Thanks. 谢谢。

It's interesting problem. 这是一个有趣的问题。 onClose callback will be not called if one clicks on the overlay (if one clicks out of the modal dialog) and the dialog will be closed. 如果一击覆盖层(如果一击出模态对话框),则不会调用onClose回调,并且该对话框将关闭。

It's funny, but jqModal.js already has the option which would be perfect to implement your requiremens. 这很有趣,但是jqModal.js已经具有可以完美实现您的需求的选项。 It's closeoverlay option of $.fn.jqm (see the line ). 它是$.fn.jqmcloseoverlay选项(请参见第一行 )。 The problem is that jqGrid don't have any public property which allows to set the option. 问题在于jqGrid没有任何公共属性可以设置该选项。 If you just modify jquery.jqGrid.src.js the closeoverlay : true to closeoverlay : false (it corresponds changing closeoverlay:!0 to closeoverlay:!1 in jquery.jqGrid.min.js ) then you will have the behavior which you need. 如果只修改jquery.jqGrid.src.jscloseoverlay : true改为closeoverlay : false (在jquery.jqGrid.min.js closeoverlay:!0更改为closeoverlay:!1 ),您将拥有所需的行为。

The problem is that I don't see any simple way to realize your requirements without modification of the code jqGrid. 问题是,在不修改代码jqGrid的情况下,我看不到任何简单的方法来实现您的需求。

UPDATED : I analysed the code of jqModal.js module one more time and I'v found simple way without changing the source code of jqGrid . 更新 :我再分析了jqModal.js模块的代码,我发现了一种简单的方式而不改变jqGrid的源代码 The analyse is difficult because the module exist only in minimized form. 由于模块仅以最小形式存在,因此分析很困难。 So it's difficult to read the code. 因此很难读取代码。

The solution: you should include the following line which changes defaults of jqModal.js module: 解决方案:您应该包括以下行,以更改jqModal.js模块的默认设置:

$.jqm.params.closeoverlay = false;

Description: the lines of jqModal.js module initialize $.jqm as 说明: 该行jqModal.js模块初始化$.jqm

$.jqm = {
    hash: {},
    open: function (s,t) { ... },
    close: function (s) { ... },
    params: {}
};

So everywhere after you includes jquery.jqGrid.min.js you have $.jqm.params as empty object. 因此,在包含jquery.jqGrid.min.js之后的任何地方,都有$.jqm.params作为空对象。 It can be used to provide default values of parameters of jqModal.js (which are not directly specified in the list of parameters of $.jqm ). 它可用于提供jqModal.js参数的默认值(未在$.jqm参数列表中直接指定)。 So you can include $.jqm.params.closeoverlay = false; 因此,您可以包含$.jqm.params.closeoverlay = false; somewhere after jquery.jqGrid.min.js (or jquery.jqGrid.src.js ) to deny closing of jqGrid dialog on clicking on the overlay. jquery.jqGrid.min.js (或jquery.jqGrid.src.js )之后的某处,以拒绝单击叠加层时关闭jqGrid对话框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM