$(document).ready(function() {} or not?

$(document).ready(function() {} or not?

stephanbstephanb Posts: 36Questions: 11Answers: 0

I see some examples that depend on datatables being initialized from inside the ready() method, but I don't see that in the documentation for datatables. Is there a special case when it should be nested as part of ready()?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,179Questions: 26Answers: 4,923
    Answer ✓

    Is there a special case when it should be nested as part of ready()?

    I'm not sure what you mean by nested.

    Basically you want to initialize Datatables after the table element is written to the document. Generally a good place for that is in $(document).ready(function(). There are times you will want to initialize after some event like the success function of a jQuery ajax() request. There are no rules or requirements except a -tag table` being available as per the HTML docs.

    Kevin

This discussion has been closed.