mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: Update hidden field of TreeMultiselectField as soon as checkboxes are clicked. Related to http://mingle.silverstripe.com/projects/air_nz_cms_enhancements/cards/139 (from r88935)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@89202 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
e36798bc9b
commit
9809c0164f
@ -263,6 +263,7 @@ TreeMultiselectField.prototype = {
|
||||
newTreeReady: function (response) {
|
||||
this.TreeDropdownField.newTreeReady(response);
|
||||
MultiselectTree.create(this.tree);
|
||||
this.tree.options.onselect = this.updateVal.bind(this);
|
||||
|
||||
// Select the appropriate items
|
||||
var selectedItems = this.inputTag.value.split(/ *, */);
|
||||
@ -272,14 +273,20 @@ TreeMultiselectField.prototype = {
|
||||
var allNodes = this.tree.getElementsByTagName('li');
|
||||
for(i=0;i<allNodes.length;i++) {
|
||||
if(isSelected[allNodes[i].getIdx()]) {
|
||||
this.tree.multiselect_handleSelectionChange(allNodes[i]);
|
||||
this.tree.selectNode(allNodes[i]);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
hideTree: function() {
|
||||
this.TreeDropdownField.hideTree();
|
||||
if(this.tree) this.updateVal();
|
||||
},
|
||||
|
||||
/**
|
||||
* Update the inputTag and humanItems from the currently selected nodes.
|
||||
*/
|
||||
updateVal: function() {
|
||||
var internalVal = humanVal = "";
|
||||
|
||||
for(i in this.tree.selectedNodes) {
|
||||
@ -289,8 +296,26 @@ TreeMultiselectField.prototype = {
|
||||
|
||||
this.inputTag.value = internalVal;
|
||||
this.humanItems.innerHTML = humanVal;
|
||||
}
|
||||
},
|
||||
|
||||
updateTreeLabel: function() {
|
||||
var treeNode;
|
||||
|
||||
if(this.inputTag.value) {
|
||||
var innerHTML = '';
|
||||
var selectedItems = this.inputTag.value.split(/ *, */);
|
||||
for(i=0;i<selectedItems.length;i++) {
|
||||
if(treeNode = $('selector-' + this.inputTag.name + '-' + selectedItems[i])) {
|
||||
innerHTML += (innerHTML?', ':'') + treeNode.getTitle();
|
||||
} else {
|
||||
innerHTML += selectedItems[i];
|
||||
}
|
||||
}
|
||||
this.humanItems.innerHTML = innerHTML;
|
||||
} else {
|
||||
this.humanItems.innerHTML = '(Choose)';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user