1
0
mirror of https://github.com/DataTables/DataTables.git synced 2024-11-29 11:24:10 +01:00

Don't initialise the xhr listener if there is no DataTable on the page

This commit is contained in:
Allan Jardine 2011-11-08 10:13:03 +00:00
parent f46a49f7f4
commit af16d8016c

View File

@ -333,12 +333,14 @@ var dtLinks = [
/* Show and syntax highlight XHR returns from the server */
$(document).ready( function () {
$('#example').dataTable().bind('xhr', function ( e, oSettings ) {
var n = document.getElementById('latest_xhr');
n.innerHTML = JSON.stringify(
JSON.parse(oSettings.jqXHR.responseText), null, 2
);
n.className = "brush: js;"
SyntaxHighlighter.highlight({}, n);
} );
if ( $.fn.dataTableSettings.length > 1 ) {
$('#example').dataTable().bind('xhr', function ( e, oSettings ) {
var n = document.getElementById('latest_xhr');
n.innerHTML = JSON.stringify(
JSON.parse(oSettings.jqXHR.responseText), null, 2
);
n.className = "brush: js;"
SyntaxHighlighter.highlight({}, n);
} );
}
} );