angular js指令中的jquery-bootgrid,无法在bootgrid中删除事件

时间:2015-11-18 02:06:29

标签: jquery angularjs

我试图触发'事件删除'在jquery-bootgrid中,我使用angular指令来执行jquery-bootgrid组件,这是我的代码:

.directive('rolesList', function ($timeout,urls) {
        return {
           restrict: 'A',
           link: function(scope,element,attr) {
               $timeout(function(){
                   element.bootgrid({
                       css: {
                           icon: 'zmdi icon',
                           iconColumns: 'zmdi-view-module',
                           iconDown: 'zmdi-expand-more',
                           iconRefresh: 'zmdi-refresh',
                           iconUp: 'zmdi-expand-less'
                       },
                       formatters: {
                           "commands": function(column, row) {
                               return "<a type=\"button\" class=\"btn btn-icon command-edit\" data-row-id=\"" + row.id + "\"><span class=\"zmdi zmdi-edit\"></span></a> " +
                                   "<a type=\"button\" class=\"btn btn-icon command-delete\" data-row-id=\"" + row.id + "\"><span class=\"zmdi zmdi-delete\"></span></a>";
                           }
                       },
                       ajax: true,
                       requestHandler: function(request) {
                           request.page = element.bootgrid("getCurrentPage");
                           return request;
                       },
                       responseHandler: function(response) {
                           response.current = response.current_page;
                           return response;
                       },
                       url: urls.BASE_API_ROLE,
                       ajaxSettings: {
                           method: "GET",
                           cache: true
                       },
                       selection: true,
                       multiSelect: true,
                       rowSelect: true,
                       keepSelection: true
                   }).on("loaded.rs.jquery.bootgrid", function() {
                       /* Executes after data is loaded and rendered */
                       element.find(".command-edit").on("click", function(e)
                       {
                           var id = $(this).data("row-id");
                           var rows = element.bootgrid("getCurrentRows");
                           //console.log(rows);
                           for (var i=0;i<rows.length;i++) {
                               if (rows[i]['id'] == id) {
                                   scope.$apply(function(){
                                       scope.rolesLabelSave = 'Save Edited Role';
                                       scope.rolesLabelState = 'Edit New Role';
                                       scope.rolesState = 'edit';
                                       scope.rolesEditID = id;
                                       scope.rolesRoleName = rows[i]['name'];
                                       scope.rolesRoleDescription = rows[i]['description'];
                                   });
                               }
                           }

                       }).end().find(".command-delete").on("click", function(e)
                       {

                           var rows = Array();
                           rows[0] = $(this).data("row-id");
                           element.bootgrid("remove",rows);

                       });
                   });
                });
           }
        }
    });

执行element.bootgrid("remove")的事件不起作用,出了什么问题?谢谢!

0 个答案:

没有答案