multiselect icon indicating copy to clipboard operation
multiselect copied to clipboard

Limit selected options

Open hossam-abdelmajeed opened this issue 4 years ago • 4 comments

How I can limit the select options, either the Right side or Left side?

hossam-abdelmajeed avatar Jul 27 '21 09:07 hossam-abdelmajeed

Hi, I think you can achieve this by using the beforeMoveRight / beforeMoveLeft callbacks.

Sent from my iPhone

On 27 Jul 2021, at 12:55, Hossam Abdelmajeed @.***> wrote:

 How I can limit the select options, either the Right side or Left side?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

crlcu avatar Jul 27 '21 16:07 crlcu

may I ask for an example (full example), as I didn't found anything but a description in the documentation? much appreciated

hossam-abdelmajeed avatar Jul 28 '21 08:07 hossam-abdelmajeed

a very simple code didn't work: beforeMoveToRight: function($left, $right, $options) { alert($options); return true; }, any suggestions?

hossam-abdelmajeed avatar Jul 28 '21 15:07 hossam-abdelmajeed

I needed to limit the amount of options being move to the $left column. This worked for me:

beforeMoveToLeft: function($left, $right, $options) { if($left.children('option').length >= 2) { return false; } else { return true; }; }

Also $options is an object. Putting it in an alert will only tell you [Object object]. console.log($options); will show you what's in the object.

Hope it helps.

jonth93 avatar Oct 01 '21 09:10 jonth93