[SOLVED] dataTable fnDraw() issue after not table-related $.ajax call
[SOLVED] dataTable fnDraw() issue after not table-related $.ajax call
SadTeo
Posts: 2Questions: 0Answers: 0
EDIT: this issue was previously correlated with jquery dialog.
I noticed this issue after any $.ajax call.
I've got a problem.
In the same page i've two set of distinct functionality: some $.ajax call, triggered by click on dom item, and a configured datatable. After any ajax interation in the page, not related to the datatable, the fnDraw() break the datatable, re-initialize it with zero configuration. I see the default command, removed in my datatable initial configuration with:
[code]"sDom" : 't<"pagination-box"p>'[/code]
the new zero-configuration table, instead of the configured one, is triggered by this call:
[code]$("#table-id").dataTable().fnDraw()[/code]
No javascript error in console.
The ajax call receive from server an html and the success callback function paste it in the page. I'm confused because there's no iteration between datatable and any ajax call and the dom of the table "table-id" is not altered by the $.ajax call.
Can someone give me a hint about this behaviour?
EDIT: the problems seems to be related to the jquery.html(data) in the success callback. I paste the server-side generated html in a specific div of the page using $("#placeholder-id").html(data). After this operation, the datatable is break: i've changed some of the code: i'm not calling the fnDraw() with the syntax $("#table-id").dataTable().fnDraw() but with oTable.fnDraw(). This result in a javascript error "oSettings is null". The same operatione, if done before the .html(data), is perfectly working.
SOLVED: The problem was a duplicated id for another table pasted in the html, with the same id of the first table.
I noticed this issue after any $.ajax call.
I've got a problem.
In the same page i've two set of distinct functionality: some $.ajax call, triggered by click on dom item, and a configured datatable. After any ajax interation in the page, not related to the datatable, the fnDraw() break the datatable, re-initialize it with zero configuration. I see the default command, removed in my datatable initial configuration with:
[code]"sDom" : 't<"pagination-box"p>'[/code]
the new zero-configuration table, instead of the configured one, is triggered by this call:
[code]$("#table-id").dataTable().fnDraw()[/code]
No javascript error in console.
The ajax call receive from server an html and the success callback function paste it in the page. I'm confused because there's no iteration between datatable and any ajax call and the dom of the table "table-id" is not altered by the $.ajax call.
Can someone give me a hint about this behaviour?
EDIT: the problems seems to be related to the jquery.html(data) in the success callback. I paste the server-side generated html in a specific div of the page using $("#placeholder-id").html(data). After this operation, the datatable is break: i've changed some of the code: i'm not calling the fnDraw() with the syntax $("#table-id").dataTable().fnDraw() but with oTable.fnDraw(). This result in a javascript error "oSettings is null". The same operatione, if done before the .html(data), is perfectly working.
SOLVED: The problem was a duplicated id for another table pasted in the html, with the same id of the first table.
This discussion has been closed.
Replies