【问题标题】:JQuery Dialog: Don't disable the backgroundJQuery 对话框:不要禁用背景
【发布时间】:2014-04-25 16:48:13
【问题描述】:

我已经看到了与 select2 插件一起使用的 JQuery 对话框示例,您仍然可以在对话框打开时访问下拉框。

我正在尝试对大约 100 行的表格中的模式执行相同的操作。

是这样的:

<table>
   <tr ng-data-repeat="inst in instances"
     <td>data bind 1</td>
     <td><a href="javascript:void(0)" class="genpopover">click to open dialog</a></td>
   </tr>
   <tr>
     <td>
        <div id="modal"></div>
     </td>
   </tr>

$('body').on("click", ".genpopover", function(){
    var $elm = $(this);
    var $tbl = $elm.parent().parent().parent().parent();
    $("#modal").dialog({  //create dialog, but keep it closed
        autoOpen: false,
        height: 300,
        width: 500,
        modal: true,
        draggable: false,
        position: {  my: "right center", at: "right top", of: $tbl},
        open: function () {
               if ($.ui && $.ui.dialog && !$.ui.dialog.prototype._allowInteractionRemapped && $(this).closest(".ui-dialog").length) {
                     if ($.ui.dialog.prototype._allowInteraction) {
                            $.ui.dialog.prototype._allowInteraction = function (e) {
                                   if ($(e.target).closest('table').length) return true;
                     return ui_dialog_interaction.apply(this, arguments);
                 };
                 $.ui.dialog.prototype._allowInteractionRemapped = true;
                }
                  else {
                      $.error("You must upgrade jQuery UI or else.");
                }
           }
        },
        _allowInteraction: function (event) {
            return !!$(event.target).is("table") || this._super(event);
         }
    });
});

【问题讨论】:

  • 根据定义,modal 对话框会阻止所有其他 UI 交互。如果您希望在对话框打开时能够做一些事情,请不要使用 modal 对话框。

标签: jquery angularjs jquery-ui jquery-dialog


【解决方案1】:

如果您不希望对话框为 modal,请将 modal 设置为 false ;-)

根据定义,模态对话框会阻止与其他组件的交互。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-22
    • 2023-04-06
    • 2011-03-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多