Skip to content

Commit

Permalink
add onControlOpen callback
Browse files Browse the repository at this point in the history
  • Loading branch information
nobleclem committed Mar 15, 2022
1 parent 3065cc6 commit f3c0d86
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
===================
resolves pr#183
resolves pr#186
add onControlOpen callback

2.4.20 (2021-12-07)
===================
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ $('select[multiple]').multiselect( 'loadOptions', [{
| checkboxAutoFit | bool | false | auto calc space requirements for checkbox instead of css padding on label |
| onLoad | function | | fires at end of initial loading, hides native select list |
| onOptionClick | function | | fires after on option is clicked |
| onControlOpen | function | | fires when the options list is open |
| onControlClose | function | | fires when the options list is closed |
| onSelectAll | function | | fires when (un)select all is clicked |
| onPlaceholder | function | | fires when the placeholder txt is updated |
Expand Down Expand Up @@ -168,6 +169,15 @@ element: select list element object
option: option element object


**onControlOpen**

Fires when the options list is opened

`onControlOpen( element )`

element: select list element object


**onControlClose**

Fires when the options list is closed
Expand Down
6 changes: 6 additions & 0 deletions jquery.multiselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
// Callbacks
onLoad : function( element ){}, // fires at end of list initialization
onOptionClick : function( element, option ){}, // fires when an option is clicked
onControlOpen : function( element ){}, // fires when the options list is opened
onControlClose: function( element ){}, // fires when the options list is closed
onSelectAll : function( element, selected ){}, // fires when (un)select all is clicked
onPlaceholder : function( element, placeholder, selectedOpts ){}, // fires when the placeholder txt is updated
Expand Down Expand Up @@ -258,6 +259,11 @@

// recalculate height
if( optionsWrap.closest('.ms-options-wrap').hasClass('ms-active') ) {
// USER CALLBACK
if( typeof instance.options.onControlOpen == 'function' ) {
instance.options.onControlOpen( instance.element );
}

optionsWrap.css( 'maxHeight', '' );

// override with user defined maxHeight
Expand Down

0 comments on commit f3c0d86

Please sign in to comment.