From 713000fc3157f71063ed8a6256a13c0e52730260 Mon Sep 17 00:00:00 2001 From: amrbedair Date: Thu, 5 Jun 2014 18:16:53 +0200 Subject: [PATCH] #850 --- .../js/jquery.saveselection.gridview.js | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/assets/js/jquery.saveselection.gridview.js b/src/assets/js/jquery.saveselection.gridview.js index 6ec85b7b..f0c0904c 100755 --- a/src/assets/js/jquery.saveselection.gridview.js +++ b/src/assets/js/jquery.saveselection.gridview.js @@ -6,21 +6,20 @@ * Init events for Bulk Actions * @param id string the ID of the grid view container */ - $.fn.yiiGridView.initBulkActions = function (id) - { - var grid = $('#'+id); + $.fn.yiiGridView.initBulkActions = function (id) { + $(document).on("click change", "#"+id+" input[type=checkbox]", function() { - - if ($("#"+id+' tbody input[type=checkbox]:checked').length) { - - $(".bulk-actions-btn", grid).removeClass("disabled"); - $("div.bulk-actions-blocker",grid).hide(); - } - else - { - $(".bulk-actions-btn", grid).addClass("disabled"); - $("div.bulk-actions-blocker",grid).show(); - } + + var grid = $('#'+id); + + if ($("#"+id+' tbody input[type=checkbox]:checked').length) { + + $(".bulk-actions-btn", grid).removeClass("disabled"); + $("div.bulk-actions-blocker",grid).hide(); + } else { + $(".bulk-actions-btn", grid).addClass("disabled"); + $("div.bulk-actions-blocker",grid).show(); + } }); }; @@ -28,19 +27,20 @@ * Updating checkboxes after grid ajax updating * @param id string the ID of the grid view container */ - $.fn.yiiGridView.afterUpdateGrid = function (id) - { - var grid = $('#'+id); + $.fn.yiiGridView.afterUpdateGrid = function (id) { + if ($("#"+id+' tbody input[type=checkbox]:checked').length) { - - $(".bulk-actions-btn", grid).removeClass("disabled"); - $("div.bulk-actions-blocker",grid).hide(); - $.each(checkedItems, function(index, item){ + + var grid = $('#'+id); + + $(".bulk-actions-btn", grid).removeClass("disabled"); + $("div.bulk-actions-blocker",grid).hide(); + $.each(checkedItems, function(index, item) { var row = $("input[value="+item+"]", grid); - if (!row.is(':checked')) { - row.attr("checked", "checked"); - } - }); + if (!row.is(':checked')) { + row.attr("checked", "checked"); + } + }); } }; @@ -48,9 +48,9 @@ * Returns array of checked items ids * @returns {Array} */ - $.fn.yiiGridView.getCheckedItems = function (id) - { - return $("#"+id+' tbody input[type=checkbox]:checked').map(function() { return $(this).val(); }).get(); + $.fn.yiiGridView.getCheckedItems = function (id) { + + return $("#"+id+' tbody input[type=checkbox]:checked').map(function() { return $(this).val(); }).get(); }