Skip to content

Commit de47fce

Browse files
author
robmadeyou
committed
Fix multiselect dropdown get value
1 parent d2ea8e3 commit de47fce

2 files changed

Lines changed: 21 additions & 12 deletions

File tree

CHANGELONG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#Changelog
22

3+
### 2.0.3
4+
* Fix multiselect dropdown get value
5+
36
### 2.0.2
47
* Disable "Add new..." by default for dropdowns
58

src/SelectizeLibraryViewBridge.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
rhubarb.vb.create('SelectizeLibraryViewBridge', function(parent) {
1+
rhubarb.vb.create('SelectizeLibraryViewBridge', function (parent) {
22
return {
3-
selectize:null,
4-
attachEvents:function() {
3+
selectize: null,
4+
attachEvents: function () {
55
parent.attachEvents.call(this);
66

77
var self = this,
88
$selectize = $(this.viewNode).selectize(
99
{
10-
options:[],
11-
create:false,
10+
options: [],
11+
create: false,
1212
load: function (query, callback) {
1313
this.clearOptions();
1414
this.renderCache = {};
1515
},
16-
loadThrottle:150,
16+
loadThrottle: 150,
1717
labelField: 'name',
1818
searchField: 'name',
1919
allowEmptyOption: true,
@@ -22,20 +22,26 @@ rhubarb.vb.create('SelectizeLibraryViewBridge', function(parent) {
2222
);
2323

2424
this.selectize = $selectize[0].selectize;
25-
26-
this.selectize.on('change', function(newValue) {
27-
self.setValue(newValue);
28-
});
2925
},
30-
populateSelectedItemsFromDom:function() {
26+
populateSelectedItemsFromDom: function () {
3127
parent.populateSelectedItemsFromDom.call(this);
3228

3329
this.setValue(this.selectize.getValue());
3430
},
35-
onReattached:function() {
31+
onReattached: function () {
3632
parent.onReattached.call(this);
3733

3834
this.selectize.onSearchChange('uniqueSearchQueryOrElseCacheWillBeUsed');
35+
},
36+
getValue: function () {
37+
// If the control only supports a single selection then just return
38+
// the first of the selected items (or false if none selected)
39+
if (!this.supportsMultipleSelection) {
40+
return parent.getValue.call(this);
41+
}
42+
else {
43+
return this.selectize.getValue();
44+
}
3945
}
4046
};
4147
}, window.rhubarb.viewBridgeClasses.DropDownViewBridge);

0 commit comments

Comments
 (0)