I need some help with selectize.js events - they dont work...
Inicialize selectize.js:
$("input[name='addTask[users]']").selectize({
valueField: 'email',
labelField: 'name',
//... more options like render...
});
And setting event:
$("input[name='addTask[users]']").selectize().on('type', function(){
alert();
});
If I typing in input nothing happens...
EDIT: No errors in console, selector is good because plugin works perfectly.
Only one event is working for me - "change".
Here si documentation:https://github.com/brianreavis/selectize.js/blob/master/docs/events.md (Also I do not understand "params" - on what the needs are and what they do)
Any hints, ideas? Examlple it pleases me...
EDIT: OK I GOT IT!!! SO - SOLUTION:
In initialization selectize.js:
$("input[name='addTask[users]']").selectize({
valueField: 'email',
labelField: 'name',
onType : eventHandler('onType'), // <----- this added
//... more options like render...
});
and BEFORE initialization:
var eventHandler = function(name) {
return function() {
alert(name + ' ' + arguments['0']); // name of event + typed string
};
};
And alert work if you start typing in input :)