Bug 36640: Fix behaviour of 'Clear filter'
It must be disabled when the main search input is empty. Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
d9448e1bda
commit
0974d1a916
|
|
@ -318,6 +318,13 @@ function KohaTable(id_selector, dt_parameters, table_settings, add_filters, defa
|
|||
}
|
||||
});
|
||||
|
||||
table_dt.on( 'search.dt', function ( e, settings ) {
|
||||
// When the DataTables search function is triggered,
|
||||
// enable or disable the "Clear filter" button based on
|
||||
// the presence of a search string
|
||||
toggledClearFilter(table_dt.search(), settings.nTable.id);
|
||||
});
|
||||
|
||||
return table;
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -75,10 +75,11 @@ var dataTablesDefaults = {
|
|||
DataTable.defaults.column.orderSequence = ['asc', 'desc'];
|
||||
|
||||
function toggledClearFilter(searchText, tableId){
|
||||
let clear_filter_button = $("#" + tableId + "_wrapper").find(".dt_button_clear_filter");
|
||||
if( searchText == "" ){
|
||||
$("#" + tableId + "_wrapper").find(".dt_button_clear_filter").addClass("disabled");
|
||||
clear_filter_button.addClass("disabled");
|
||||
} else {
|
||||
$("#" + tableId + "_wrapper").find(".dt_button_clear_filter").removeClass("disabled");
|
||||
clear_filter_button.removeClass("disabled");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1076,7 +1077,7 @@ function _dt_save_restore_state(table_settings, external_filter_nodes={}){
|
|||
// When the DataTables search function is triggered,
|
||||
// enable or disable the "Clear filter" button based on
|
||||
// the presence of a search string
|
||||
toggledClearFilter(settings.oPreviousSearch.sSearch, settings.nTable.id);
|
||||
toggledClearFilter(table_dt.search(), settings.nTable.id);
|
||||
});
|
||||
|
||||
return table;
|
||||
|
|
|
|||
Loading…
Reference in New Issue