1

I am using bootstrap nav-tabs. tabs content are loaded via ajax and there are two tables within ajax loaded content. I want to bind datatable jquery plugin for these tables but I don't know how. I know I have to use 'delegate' method but I know where and how.

Thank you.

2
  • what you reference is about load data of datatable via ajax, what I've asked is another question. apply datatable to content of tabs which is loaded via ajax. Commented Jul 14, 2016 at 13:28
  • thank you but it is not about my question. Commented Jul 14, 2016 at 13:31

1 Answer 1

1

I think you need to bind it after the ajax ajax is complete. This is a way to do this.

    $.ajax({
        url: '/path/to/file',
        type: 'default GET (Other values: POST)',
        dataType: 'default: Intelligent Guess (Other values: xml, json, script, or html)',
        data: {param1: 'value1'},
    })
    .done(function() {
        console.log("success");
    })
    .fail(function() {
        console.log("error");
    })
    .always(function() {

        // after the ajax is complete, this function is 
        // called and you can bind the datatable function on your table
        $('#tableID').dataTable();

        console.log("complete");
    });
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.