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