How to mark row as favorites in datatables?

How to mark row as favorites in datatables?

adrian____adrian____ Posts: 1Questions: 1Answers: 0

I was trying to make the datatable redraw, based on user's click on a row. The datatable is as following:

            var oTable = $('#posts-table').DataTable({
            processing: true,
            serverSide: true,
            "rowCallback": function( row, data ) {

                    // how can I notify server which row has been clicked?

            },
            ajax: {
                url:  '{!! route('post.data') !!}',
                data: function (d) {
                    d.name = $('input[name=name]').val();
                }
            },
              aoColumns: [
                { data: 'likes', name: 'likes', searchable: false},
                { data: 'price', name: 'price' },
                { data: 'type', name: 'type' }

            ],
            order: [[0, 'desc']]
        });

On the click:

       $('#posts-table tbody').on('click', 'a.likes', function(e) {
            var i = $(this).find('i');
            if ( i.hasClass('glyphicon-heart-empty')) {
                i.removeClass('glyphicon-heart-empty')
                        .addClass('glyphicon-heart');

            } else {
                i.removeClass('glyphicon-heart')
                        .addClass('glyphicon-heart-empty');
            }


            oTable.draw();
            e.preventDefault();
        });

Should I use rowCallback option? But how can I let the server know which data record to update according to the user's click? Thanks.

This discussion has been closed.