简体   繁体   English

jQuery-bootgrid模式对话框

[英]jQuery-bootgrid modal dialog

I have a jQuery-bootgrid as described in the examples on the homepage. 我有一个jQuery-bootgrid,如主页上的示例中所述。 In the last column I have two buttons for Edit/Delete of the row-content. 在最后一列中,我有两个用于编辑/删除行内容的按钮。

All I want to do is to show a modal dialog when the user clicks the Delete-button. 我想要做的就是在用户单击“删除”按钮时显示模式对话框。 However, nothing happens on click. 但是,点击没有任何反应。 No error, no warning, nothing. 没有错误,没有警告,没有。

Here is the code for the bootgrid commands-part: 这是bootgrid命令部分的代码:

"commands": function(column, row) {
                return "<button type=\"button\" class=\"btn btn-sm btn-primary command-edit\" data-row-id=\"" + row.EventId + "\"><span class=\"icon glyphicon glyphicon-pencil\"></span>@Translator.TranslateGlobal(Keys.Global.Edit)</button> " +
                    "<button class=\"btn-default btn\" data-content-close=\"Close\" data-content-id=\"Div\" data-content-save=\"Save\" data-target=\"#6698CB2F-2948-45D9-8902-2C13A7ED6335\" data-title=\"Title\" data-toggle=\"modal\" type=\"button\">Show modal</button>";
            },

I have the exact same button outside the bootgrid and on click it shows the dialog as expected. 我在bootgrid外面有完全相同的按钮,单击它会按预期显示对话框。 Any ideas where to look at or what is causing this behavior? 任何想法在哪里查看或导致这种行为的原因是什么?

Opening Modal on click Event Reference 单击“事件参考”打开“模态”

  formatters: {
            "commands": function (column, row) {
                return "<button type=\"button\" class=\"btn btn-xs btn-default command-edit\"  data-toggle=\"modal\" data-target=\"#confirmation\"><span class=\"fa fa-pencil\"></span></button> " +
                    "<button type=\"button\" class=\"btn btn-xs btn-default command-delete\" ><span class=\"fa fa-trash-o\"></span></button>";
            }
        }
    }).on("loaded.rs.jquery.bootgrid", function () {
        /* Executes after data is loaded and rendered */
        $(this).find(".command-delete").click(function (e) {
            $($(this).attr("data-target")).modal("show");
        });
    });

Hope it works :) 希望它有效:)

its an excellent idea, Could you please show in a script format please. 这是一个很好的主意,请你以脚本格式表示。 Which part of the script we can replace. 我们可以替换哪部分脚本。

That way you don't have to reapply the handler if the grid pages, and there are many fewer event handlers (more efficient): $('table').on("click",".command-delete", function(e){ console.log('your stuff happens here'); }); 这样你就不必重新应用处理程序,如果网格页面,并且有更少的事件处理程序(更有效):$('table')。on(“click”,“。command-delete”,function( e){console.log('你的东西发生在这里');}); – philw Jun 26 - 6月26日

 formatters: {
        "commands": function (column, row) {
            return "<button type=\"button\" class=\"btn btn-xs btn-default command-edit\"  data-toggle=\"modal\" data-target=\"#confirmation\"><span class=\"fa fa-pencil\"></span></button> " +
                "<button type=\"button\" class=\"btn btn-xs btn-default command-delete\" ><span class=\"fa fa-trash-o\"></span></button>";
        }
    }
}).on("loaded.rs.jquery.bootgrid", function () {
    /* Executes after data is loaded and rendered */
    $(this).find(".command-delete").click(function (e) {
        $($(this).attr("data-target")).modal("show");
    });
});

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

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