DataTables: disable action buttons even if there are no checkboxes

Even if there are no checkboxes, we should disable action buttons
instead of just doing nothing.

Closes-bug: #1263673
Change-Id: Ib20504162e7ffb54c6f6427b364276b13857af3b
This commit is contained in:
Ivan A. Melnikov 2013-12-23 14:16:40 +02:00
parent 58feb1a0fd
commit d860d9dcaa
1 changed files with 5 additions and 7 deletions

View File

@ -113,13 +113,11 @@ horizon.datatables = {
// Disable form button if checkbox are not checked
$("form").each(function (i) {
var checkboxes = $(this).find(".table-row-multi-select:checkbox");
if(!checkboxes.length) {
// Do nothing if no checkboxes in this form
return;
}
if(!checkboxes.filter(":checked").length) {
$(this).find(".table_actions button.btn-danger").addClass("disabled");
}
var action_buttons = $(this).find(".table_actions button.btn-danger");
// Buttons should be enabled only if there are checked checkboxes
action_buttons.toggleClass("disabled",
!checkboxes.filter(":checked").length);
});
}
};