0

Here's what I'm attempting to do:

I have an edit button within every row. when the user clicks on that edit button, I need to get the index of that row..but I'm not sure how exactly to do that. Anyone know how to do this? Please check out my Datatables live link below to further understand my problem and make any necessary changes.

Datatables live link: http://live.datatables.net/madadak/2/edit

Thanks!

1 Answer 1

3

Change the jQuery code to be this:

$(document).ready( function () {
var table = $('#example').DataTable();
    $("#example tbody").on('click', '.editButton', function() {
        alert('Row index:' + $(this).closest('tr').prevAll().length );
    });                      
} );

It starts with index 0 which I hope is what you want. I found it here if you're wondering.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.