0

如何更改此小提琴中的“警报”单击事件以删除单击图标的行?我尝试了几种方法,但都没有奏效。我想删除/删除该行,而不是发布警报。先感谢您。

这是小提琴

        function actionFormatter(value, row, index) {
        return [
    '<a class="like" href="javascript:void(0)" title="Like">',
    '<i class="glyphicon glyphicon-heart"></i>',
    '</a>',
    '<a class="edit ml10" href="javascript:void(0)" title="Edit">',
    '<i class="glyphicon glyphicon-edit"></i>',
    '</a>',
    '<a class="remove ml10" href="javascript:void(0)" title="Remove">',
    '<i class="glyphicon glyphicon-remove"></i>',
    '</a>'
       ].join('');
          }

   window.actionEvents = {
     'click .like': function (e, value, row, index) {
    alert('You click like icon, row: ' + JSON.stringify(row));
    console.log(value, row, index);
},
'click .edit': function (e, value, row, index) {
    alert('You click edit icon, row: ' + JSON.stringify(row));
    console.log(value, row, index);
},
'click .remove': function (e, value, row, index) {
    alert('You click remove icon, row: ' + JSON.stringify(row));
    console.log(value, row, index);
     }
      };
4

1 回答 1

0

添加: var $table = $('#table')

这对点击函数:'click .remove': function (e, value, row, index) { $table.bootstrapTable('remove', { field: 'id', values: [row.id] });

现在它起作用了。

      var   $table = $('#table')

 function actionFormatter(value, row, index) {
    return [
'<a class="like" href="javascript:void(0)" title="Like">',
'<i class="glyphicon glyphicon-heart"></i>',
'</a>',
'<a class="edit ml10" href="javascript:void(0)" title="Edit">',
'<i class="glyphicon glyphicon-edit"></i>',
'</a>',
'<a class="remove ml10" href="javascript:void(0)" title="Remove">',
'<i class="glyphicon glyphicon-remove"></i>',
'</a>'
   ].join('');
      }

   window.actionEvents = {
     'click .like': function (e, value, row, index) {
    alert('You click like icon, row: ' + JSON.stringify(row));
    console.log(value, row, index);
},
'click .edit': function (e, value, row, index) {
    alert('You click edit icon, row: ' + JSON.stringify(row));
    console.log(value, row, index);
},
    'click .remove': function (e, value, row, index) {
               $table.bootstrapTable('remove', {
                field: 'id',
                values: [row.id]
            });
    }
};
于 2015-05-15T14:11:07.997 回答