Skip to content

Commit

Permalink
Auto title checking works if a title is checked instead of just items
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Tsai committed Aug 23, 2015
1 parent fa25648 commit 283cfce
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion jquery.tree-multiselect.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions jquery.tree-multiselect.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery.tree-multiselect.js",
"version": "1.12.1",
"version": "1.12.2",
"description": "jQuery multiple select with nested options",
"main": "jquery.tree-multiselect.min.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/jquery.tree-multiselect.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* jQuery Tree Multiselect
* v1.12.1
* v1.12.2
*
* (c) Patrick Tsai
* MIT Licensed
Expand Down
4 changes: 2 additions & 2 deletions src/jquery.tree-multiselect.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* jQuery Tree Multiselect
* v1.12.1
* v1.12.2
*
* (c) Patrick Tsai
* MIT Licensed
Expand Down Expand Up @@ -267,7 +267,7 @@
});
}

var checkboxes = $(selectionContainer).find("div.item > input[type=checkbox]");
var checkboxes = $(selectionContainer).find("input[type=checkbox]");
checkboxes.change(function() {
check();
});
Expand Down
16 changes: 16 additions & 0 deletions test/integration/title-autochecking.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,19 @@ QUnit.test("titles should unselect when a child is unselected", function(assert)

assert.ok(!($("div.title > input[type=checkbox]").is(":checked")), "title should not be checked now");
});

QUnit.test("nested titles should all be checked if a title is batch selected", function(assert) {
$("select").append("<option value='one' data-section='top/middle/inner'>One</option>");
$("select").treeMultiselect();

assert.equal($("input[type=checkbox]").length, 4, "there should be four checkboxes");
assert.equal($("input[type=checkbox]:checked").length, 0, "no checkboxes should be checked");

var middleSection = $("div.section").filter(function() {
return textOf($(this).find("> div.title")) == 'middle';
});

middleSection.find("> div.title > input[type=checkbox]").prop('checked', true).trigger('change');

assert.equal($("input[type=checkbox]:checked").length, 4, "all checkboxes should be checked");
});

0 comments on commit 283cfce

Please sign in to comment.