main table var returning undefined
main table var returning undefined
Hi,
I'm trying to reload my table data after a submitSuccess but I'm getting an undefined error against my var qsjobTable.
I declare the var at the beginning of my scripts and outside of the $(document).ready function:
var qsjobTable;
Then it is used on my main DT as so:
var qsjobTable = $("#dtqsjob").DataTable({
Then I added the script below, but this throws the error after I create or edit a record.
<script>
$(document).ready(function() {
qsjob_editor.on('submitSuccess', function (e, json, data, action, xhr) {
console.log("submitSuccess called");
consoie.log(qsjobTable);
qsjobTable.ajax.reload();
});
}); // Document Ready
</script>
I can reference the editor var just fine, but not the table var.
Any advice\ideas appreciated?
Cheers, Chris
This question has an accepted answers - jump to answer
Answers
Its a Javascript scoping issue. My guess is this statement:
Probably should just be this to keep the variable in the global scope:
If this doesn't help then we will need to see your full code as the code snippets won't help us understand where the variable is out of scope. Please post a link to your page or a test case so we can take a look.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Should have spotted that Thank you kthorngren