首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jQuery-bootgrid模式对话框

jQuery-bootgrid模式对话框
EN

Stack Overflow用户
提问于 2015-03-13 18:50:59
回答 2查看 1.8K关注 0票数 3

我有一个jQuery-bootgrid,如主页上的示例所述。在最后一列中,我有两个用于编辑/删除行内容的按钮。

我所要做的就是在用户单击Delete-按钮时显示一个模式对话框。但是,单击时什么也不会发生。没有错误,没有警告,什么都没有。

下面是bootgrid命令的代码-part:

代码语言:javascript
复制
"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>";
            },

我在bootgrid之外有完全相同的按钮,单击它会显示预期的对话框。有没有什么办法可以看一看,或者是什么导致了这种行为?

EN

回答 2

Stack Overflow用户

发布于 2015-06-17 03:37:54

在单击事件Reference时打开模态

代码语言:javascript
复制
  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");
        });
    });

希望它能正常工作:)

票数 3
EN

Stack Overflow用户

发布于 2018-09-10 17:40:46

这是一个很好的想法,可以请你在一个脚本格式显示。我们可以替换脚本的哪一部分。

这样你就不必在网格页面时重新应用处理程序,事件处理程序也更少(效率更高):$('table').on("click",".command-delete",function(e){ console.log('your stuff here');});- philw Jun 26

代码语言:javascript
复制
 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");
    });
});
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29030352

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档