Reputation: 1848
I'm trying to use <select multiple="multiple"></select>
with selectize.js. I did it like this:
index.html
<select multiple="multiple" id="to"></select>
script
$('#to').selectize({
plugins: ['remove_button'],
persist: false,
create: function(input){
return {
value: input,
text: input
}
},
valueField: 'email',
labelField: 'email',
searchField: ['email'],
options: JSON.parse('{{ $email }}'),
render: {
item: function(item, escape){
return '<div>' +
(item.email ? '<code>' + escape(item.email) + '</code>' : '') +
'</div>';
},
option: function(item, escape){
var caption = item.email ? item.email : null;
return '<div>' +
(caption ? '<span class="text-primary">' + escape(caption) + '</span>' : '') +
'</div>';
}
}
});
It is working fine, but what I want is to also allow the user to add more item. Any solution for this?
Upvotes: 1
Views: 1401
Reputation: 11
add maxItems: number-of-options as per the documentation https://selectize.dev/docs.html
Upvotes: 0