Closed anatoliy-t7 closed 4 months ago
max
controls amount of selected options. There is no limit how many items can user create. It's irrelevant, because only selectied items matters (from components' point of view)
Does it answer your question?
Yes. Thank you. I need to find a way to limit of created items.
You can use your own createHandler
and internally count number of created items. And throw an error when new item shouldn't be created.
I did it. But it is still added in DOM but not in value.
function onCreateOption(option: { value: any }) {
if (value.length < max) {
value.push(option.value);
value = value;
}
}
Actually you want to do something like in this REPL:
createHandler
and throw an error when you want to avoid creating additional item.createFail
event as you like.I found some issues with related code, so update to the latest 4.2.3
stable version. If you are using svelecte@next
, I will update it in a minute...
Hello.
How do I can control
max
forcreatable
items?Thank you for the great component.