@@ -10210,6 +10210,7 @@ define('select2/core',[
1021010210 this . data = new this . options . dataAdapter ( $element , this . options ) ;
1021110211
1021210212 var $container = this . render ( ) ;
10213+ this . $container = $container ;
1021310214
1021410215 $container . insertAfter ( this . $element ) ;
1021510216
@@ -10253,18 +10254,26 @@ define('select2/core',[
1025310254 } ) ;
1025410255
1025510256 this . selection . on ( "toggle" , function ( ) {
10256- $container . toggleClass ( "open" ) ;
10257+ self . toggleDropdown ( ) ;
1025710258 } ) ;
1025810259
1025910260 this . results . on ( "selected" , function ( params ) {
1026010261 self . trigger ( "select" , params ) ;
1026110262
10262- $container . removeClass ( "open ") ;
10263+ self . trigger ( "close ") ;
1026310264 } ) ;
1026410265
1026510266 this . results . on ( "unselected" , function ( params ) {
1026610267 self . trigger ( "unselect" , params ) ;
1026710268
10269+ self . trigger ( "close" ) ;
10270+ } ) ;
10271+
10272+ this . on ( "open" , function ( ) {
10273+ $container . addClass ( "open" ) ;
10274+ } ) ;
10275+
10276+ this . on ( "close" , function ( ) {
1026810277 $container . removeClass ( "open" ) ;
1026910278 } ) ;
1027010279
@@ -10287,6 +10296,14 @@ define('select2/core',[
1028710296
1028810297 Utils . Extend ( Select2 , Utils . Observable ) ;
1028910298
10299+ Select2 . prototype . toggleDropdown = function ( ) {
10300+ if ( this . $container . hasClass ( "open" ) ) {
10301+ this . trigger ( "close" ) ;
10302+ } else {
10303+ this . trigger ( "open" ) ;
10304+ }
10305+ }
10306+
1029010307 Select2 . prototype . render = function ( ) {
1029110308 var $container = $ (
1029210309 '<span class="select2 select2-container select2-theme-default">' +
0 commit comments