1

I have a datatable which will be model binded when the page opens but when i am doing any edit or delete function the the datatable will be binded using ajax call. So I am having a function

 $('#user-detail-datatable tbody tr td a').on('click', function () {

        //prepoluting values on edit
        $("#CarryUser").val($(this).closest('tr').find('td')[5].outerText);
        d = $(this).closest('tr').find('a')[1].id;
        $("#display").val($(this).closest('tr').find('td')[6].outerText);
        UsingBranchId = $(this).closest('tr').find('td')[2].outerText;
        $("#fileUpload").val($(this).closest('tr').find('td')[0].outerText);
    });

used to get the values from datatable to bind a model which will open on click of edit button. but this function is not getting hit after I am editing or deleting can anyone explain why. And help me out

1 Answer 1

2

You would need to use a delegated event handler. As for now you have one time binding to elements which is lost as soon the table is updated. Use

$('#user-detail-datatable').on('click', 'tbody tr td a', function () {
}]

instead.

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.