Bug 25274: Don't initialize DataTable if table isn't present

This patch modifies the OPAC basket JavaScript so that a check is added
for the existence of the "itemst" table. This avoids an error if the
"More details" view is selected and hte "itemst" table isn't present.

To reproduce the error, add some items to the OPAC cart and open the
cart window. Open the JavaScript console in your browser and click the
"More details" link. You'll see an error.

To test, apply the patch and perform the same test as above. The error
should not be present. Test that table sorting in the "brief" view words
correctly.

Signed-off-by: David Roberts <david@koha-ptfs.co.uk>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Owen Leonard 2020-04-24 11:49:21 +00:00 committed by Joy Nelson
parent bfa97dc73c
commit 2c9e0ac020
1 changed files with 20 additions and 19 deletions

View File

@ -428,26 +428,27 @@
return false;
});
var itemst = $("#itemst").dataTable($.extend(true, {}, dataTablesDefaults, {
"order": [[ 1, "asc" ]],
"columnDefs": [
{ "targets": [ 0,-1 ], "sortable": false, "searchable": false }
],
"columns": [
null,
{ "type": "anti-the" },
null,
null,
null
],
if( $("#itemst").length > 0 ){
var itemst = $("#itemst").dataTable($.extend(true, {}, dataTablesDefaults, {
"order": [[ 1, "asc" ]],
"columnDefs": [
{ "targets": [ 0,-1 ], "sortable": false, "searchable": false }
],
"columns": [
null,
{ "type": "anti-the" },
null,
null,
null
],
}));
}));
var buttons = new $.fn.dataTable.Buttons(itemst, {
buttons: [
'print'
]
}).container().appendTo($('#toolbar'));
var buttons = new $.fn.dataTable.Buttons(itemst, {
buttons: [
'print'
]
}).container().appendTo($('#toolbar'));
}
$(".cb").change(function(){
selRecord( $(this).val(), $(this).prop("checked") );