Skip to content
Snippets Groups Projects
Commit 6f7b1f52 authored by Tim Neumann's avatar Tim Neumann
Browse files

Improve logic which handles "hide done" on transports list

The new logic does not trigger a click on the checkbox,
but just sets the checked state.
Additionally the table is updated according to the checked state
at the end of the ready function.

Solves: #17
parent d93650b9
No related branches found
No related tags found
1 merge request!20Improve logic which handles "hide done" on transports list
......@@ -88,6 +88,18 @@
<script type="text/javascript">
var table;
function updateHideDone() {
if ($('#hideDone').is(':checked')) {
$.fn.dataTable.ext.search.push(
function (settings, data, dataIndex) {
return data[12] == "open";
});
} else {
$.fn.dataTable.ext.search.pop();
}
table.draw()
}
$(document).ready(function () {
table = $('#transportlist').DataTable( {
order: [[2, "asc"]],
......@@ -101,20 +113,14 @@
$('#hideDone').on('change', function() {
localStorage.setItem('hideDone', $(this).is(':checked'));
if ($(this).is(':checked')) {
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
return data[12] == "open";
});
} else {
$.fn.dataTable.ext.search.pop();
}
table.draw()
updateHideDone()
});
if (localStorage.getItem('hideDone') === "true") {
$('#hideDone').click();
$('#hideDone').prop('checked', true);
}
updateHideDone()
});
</script>
{% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment