I'm using the selectize.js package in my application (https://github.com/selectize/selectize.js), and i'm trying to not show dropdown menu when the selectize is on focus and enable only when user start to typing. Bellow is my selectize object from contacts example (https://github.com/selectize/selectize.js/blob/master/examples/contacts.html).
$('#select-to').selectize({
persist: false,
maxItems: null,
valueField: 'email',
labelField: 'name',
searchField: ['first_name', 'last_name', 'email'],
sortField: [
{field: 'first_name', direction: 'asc'},
{field: 'last_name', direction: 'asc'}
],
options: [
{email: '[email protected]', first_name: 'Nikola', last_name: 'Tesla'},
{email: '[email protected]', first_name: 'Brian', last_name: 'Reavis'},
{email: '[email protected]'}
],
render: {
item: function(item, escape) {
var name = formatName(item);
return '<div>' +
(name ? '<span class="name">' + escape(name) + '</span>' : '') +
(item.email ? '<span class="email">' + escape(item.email) + '</span>' : '') +
'</div>';
},
option: function(item, escape) {
var name = formatName(item);
var label = name || item.email;
var caption = name ? item.email : null;
return '<div>' +
'<span class="label">' + escape(label) + '</span>' +
(caption ? '<span class="caption">' + escape(caption) + '</span>' : '') +
'</div>';
}
},
createFilter: function(input) {
var regexpA = new RegExp('^' + REGEX_EMAIL + '$', 'i');
var regexpB = new RegExp('^([^<]*)\<' + REGEX_EMAIL + '\>$', 'i');
return regexpA.test(input) || regexpB.test(input);
},
create: function(input) {
if ((new RegExp('^' + REGEX_EMAIL + '$', 'i')).test(input)) {
return {email: input};
}
var match = input.match(new RegExp('^([^<]*)\<' + REGEX_EMAIL + '\>$', 'i'));
if (match) {
var name = $.trim(match[1]);
var pos_space = name.indexOf(' ');
var first_name = name.substring(0, pos_space);
var last_name = name.substring(pos_space + 1);
return {
email: match[2],
first_name: first_name,
last_name: last_name
};
}
alert('Invalid email address.');
return false;
}
});
Is there any workaround for it? Thank you in advance !