I'm new in using selectize.js, and this is the simplified version of my problem. Please see fiddle below.
Fiddle
What I want is not to select the item when it is already selected.
Ex.
- click the Add button and then select the full name.
- click the Add again.
- Full name should not be selected in the second
<select>
or should not be visible.
How will I be able to do this?
HTML
<button>Add</button><br/><br/>
<div id="container"></div>
JS
var saveAsOptions = [
{ value: 'full-name', text: 'Full Name' },
{ value: 'first-name', text: 'First Name' },
{ value: 'last-name', text: 'Last Name' }
];
var i = 1;
var $selectSaveAs;
$('button').on('click', function(){
$('#container').append(generateSaveAs(i));
$selectSaveAs = $('#saveAs' + i).selectize({
options: saveAsOptions,
placeholder: '- Fields -'
});
i++;
});
function generateSaveAs(id){
return '<select id="saveAs' + id + '"></select>';
}