Get datatable's row data on button click

前端 未结 2 723
隐瞒了意图╮
隐瞒了意图╮ 2021-02-06 07:52

i have a problem with this project.

I\'m trying to create a crud menu, when hitting the Edit button the row\'s data will be transferred to a bootstrap modal and from the

2条回答
  •  攒了一身酷
    2021-02-06 08:17

    Got it...

    $('#example tbody').on('click', '.edit_btn', function () {
    
         var data_row = table.row( $(this).parents('tr') ).data(); // here is the change
        $("#myModal").modal('show');
    
        $('#myModal').on('shown.bs.modal', function() {
    
           $('#name').val(data_row.id);
            $('#type').val(data_row.type);
            $('#camp').html(data_row.campaign);
    
        });
    
    });
    

提交回复
热议问题