question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Limiting number of items

See original GitHub issue

Would love this feature to be built into the select. Selectize has a property called maxItems.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
cibernoxcommented, Feb 4, 2016

Oh I see it now. At the moment I handle that myself with onchange + onopen.

{{#power-select options=options 
  selected=selected 
  onchange=(action "updateUnlessFull") 
  onopen=(action 'closeIfFull") as |opt|}}
  {{opt}}
{{/power-select}}
actions: {
 closeIfFull(select) {
   if (this.get('selected.lenght') >= 5) { 
     select.actions.close() 
    }
  },
  updateUnlessFull(newOpts) {
   if (this.get('selected.lenght') < 5) { 
      this.set('selected', newOpts); 
    }
  }
}
1reaction
BananaNeilcommented, Sep 25, 2019

@bmfay I found a solution in which I set the dropdownClass option to ‘hidden’ if the selection was full, and then added a global style to my applicaion .hidden { display: none; }

selectFull: computed.gt('selectedItems.length', 2)

{{#power-select-multiple
    selected=selectedItems
    options=options
    dropdownClass=(if selectFull 'hidden')
    as |item|}}
...
{{/power-select-multiple}}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Limit the number of items in a SharePoint list - kalmstrom.com
A SharePoint tutorial by Peter Kalmstrom · Create a list with the maximum number of items. · Set the validation for new items...
Read more >
I want to limit the number of items that can be entered into a list.
I want to limit the number of items that can be entered into a list. Anyone have any suggestions on how to achieve...
Read more >
how to limit number of items in a list? - Stack Overflow
I have a custom list in my sharepoint 2010 site. I want to set a limit to the list, that after reaching the...
Read more >
How to limit the number of items displayed in collection list?
Go to 'elements settings' (collection list) then 'limit items '. Here you can choose the number of items to be shown.
Read more >
Limiting the number of items in an array - Klaviyo Community
You can use the “slice” filter to limit how many items from the list are displayed. This is a Django template language filter...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found