From f3c0d86c398539ef4906023bef2f1beacb132421 Mon Sep 17 00:00:00 2001 From: Patrick Springstubbe Date: Tue, 15 Mar 2022 12:49:29 -0400 Subject: [PATCH] add onControlOpen callback --- CHANGELOG | 1 + README.md | 10 ++++++++++ jquery.multiselect.js | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 482b4b9..e24b787 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ =================== resolves pr#183 resolves pr#186 +add onControlOpen callback 2.4.20 (2021-12-07) =================== diff --git a/README.md b/README.md index 01cb3d0..144d745 100644 --- a/README.md +++ b/README.md @@ -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 | @@ -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 diff --git a/jquery.multiselect.js b/jquery.multiselect.js index 8463744..e8b638c 100644 --- a/jquery.multiselect.js +++ b/jquery.multiselect.js @@ -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 @@ -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