I have a datatable in each of my tabs. adding a record fails to add to the correct tab
I have a datatable in each of my tabs. adding a record fails to add to the correct tab
drfunk
Posts: 58Questions: 8Answers: 0
in DataTables
This question has an accepted answers - jump to answer
Answers
You are assigning all the Datatables to the same
table
variable, for example the last Datatable initialized:This is the function for the first table:
Its using the same
table
variable which is assigned to#modexcl5
. There are lots of ways to fix this. The easiest is to use different variables, liketable1
, etc.Kevin
Thanks Kevin,
I used different vars for table but it is still adding to the last tab
http://live.datatables.net/duvusoti/1/edit
Looks like you have the same problem with the dialog form, for example:
The last one created is for the last table. I would look at creating one set of function to handle all the tables and pass in the table id instead of creating a set of similar functions for each table. This way you don't need table1, dialog1, table2, dialog2, etc. Will make it easier to add another tab.
Kevin
ok can you show me how to pass in the table id?
Here is a simple example that calls a function to get the count of rows in the table:
http://live.datatables.net/xikegodo/1/edit
Kevin
http://live.datatables.net/duvusoti/1/edit
getting "Script error. (line 0)"
Look at the browser's console not the JS Bin console tab. You will see this error:
You have this:
The
this
in the third line is provided by the click event in the example I provided. It won't work where you placed it. Without digging through your code to understand what you have done I don't have an answer of how to refactor it to do what you want. We will help with Datatables specific questions but Stack Overflow is a better resource for general Javascript coding.Kevin