serverside not executing JavaScript
serverside not executing JavaScript
fisharebest
Posts: 17Questions: 1Answers: 0
I have a datatable with a serverside data source.
It also uses row-details (also a serverside data source), as per this http://datatables.net/examples/server_side/row_details.html
I want to add JavaScript into both table cells and the row details. Something simple, such as
alert("hello");
Now, this works fine in Firefox. But in many other browsers (such as Chrome), it only works in the row-details. The JavaScript in the table cells is never executed.
Does datatables use the same method for inserting content for both the table cells and the detail row?
It also uses row-details (also a serverside data source), as per this http://datatables.net/examples/server_side/row_details.html
I want to add JavaScript into both table cells and the row details. Something simple, such as
alert("hello");
Now, this works fine in Firefox. But in many other browsers (such as Chrome), it only works in the row-details. The JavaScript in the table cells is never executed.
Does datatables use the same method for inserting content for both the table cells and the detail row?
This discussion has been closed.
Replies
Allan
I guess my data source can provide the JS in a hidden column, to make it easier for the client code to pull out.
[code]
"fnDrawCallback": function() {
// Our JSON responses include JavaScript as well as HTML. This does not get
// executed (except for some versions of Firefox?). So, extract it, and add
// it to its own DOM element
jQuery('#table script').each(function() {
var script=document.createElement('script');
script.type='text/javascript';
jQuery(script).text(jQuery(this).text());
document.body.appendChild(script);
}).remove();
}
[/code]