From 0ae25565cac88487f83069ab48c6386a10d9e4cf Mon Sep 17 00:00:00 2001 From: Matt Joyce Date: Thu, 28 Jun 2012 17:53:06 -0700 Subject: [PATCH] Fixes behavior of the 'check-all' checkbox in tables. Currently the on('click') delegate is being invoked several times from the wrong place, thus allowing another on('click') delegate to be executed before this one, which changes the expected behavior. Fixes bug 1019088 Change-Id: Iba2b3549090f7bd42fc8b029ed42163951cb9e22 --- horizon/static/horizon/js/horizon.tables.js | 25 ++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/horizon/static/horizon/js/horizon.tables.js b/horizon/static/horizon/js/horizon.tables.js index 6a893c73c..d6ddc22b5 100644 --- a/horizon/static/horizon/js/horizon.tables.js +++ b/horizon/static/horizon/js/horizon.tables.js @@ -115,19 +115,6 @@ horizon.datatables = { $(this).find(".table_actions button.btn-danger").addClass("disabled"); } }); - - $("div.table_wrapper, div.modal_wrapper").on("click", ':checkbox', function (evt) { - var $form = $(this).closest("form"); - var any_checked = $form.find("tbody :checkbox").is(":checked"); - - // Enable the button if any checkbox is checked, - // Disable if all checkbox is cleared - if(any_checked) { - $form.find(".table_actions button.btn-danger").removeClass("disabled"); - }else { - $form.find(".table_actions button.btn-danger").addClass("disabled"); - } - }); } }; @@ -223,6 +210,18 @@ horizon.addInitFunction(function() { checkboxes.prop('checked', is_checked); }); + $("div.table_wrapper, div.modal_wrapper").on("click", ':checkbox', function (evt) { + var $form = $(this).closest("form"); + var any_checked = $form.find("tbody :checkbox").is(":checked"); + // Enable the button if any checkbox is checked, + // Disable if all checkbox is cleared + if(any_checked) { + $form.find(".table_actions button.btn-danger").removeClass("disabled"); + }else { + $form.find(".table_actions button.btn-danger").addClass("disabled"); + } + }); + horizon.datatables.add_table_checkboxes($('body')); horizon.datatables.set_table_sorting($('body')); horizon.datatables.set_table_filter($('body'));