Skip to content

Commit

Permalink
Select all/unselect all speedup
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Tsai committed Oct 18, 2016
1 parent bae5805 commit 36b036f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/jquery.tree-multiselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,19 @@

$selectionContainer.prepend($selectAllContainer);

var $checkboxes = $selectionContainer.find("div.item").find("> input[type=checkbox]");

$selectionContainer.on("click", "span.select-all", function() {
$checkboxes.prop('checked', true).change();
handleCheckboxes(true);
});

$selectionContainer.on("click", "span.unselect-all", function() {
$checkboxes.prop('checked', false).change();
handleCheckboxes(false);
});

function handleCheckboxes(checked) {
var $checkboxes = $selectionContainer.find("input[type=checkbox]");
$checkboxes.prop('checked', checked);
$checkboxes.first().change();
}
}

function updateSelectedAndOnChange($selectionContainer, $selectedContainer, $originalSelect, options) {
Expand Down
2 changes: 1 addition & 1 deletion test/test-performance.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<script type="text/javascript">
var $select = $('#test-select');
for (var ii = 0; ii < 10000; ++ii) {
for (var ii = 0; ii < 2000; ++ii) {
var $option = $('<option value="fruit' + ii +'" data-section="Smoothies/' + ii + '" data-description="The greatest flavor" selected="selected">Passion Fruit</option>');
$select.append($option);
}
Expand Down

0 comments on commit 36b036f

Please sign in to comment.