How to get this element on event
how to get THIS element on event , example: on event "onItemAdd" I want to get this select box object , and from the object I want get data on it.
//jquery var eventHandler = function (item) { return function () { //how can I get the cbselect object and get data hiddenname here
};
};
$('#cbselect').selectize({ create: function (input, callback) { return { value: input, text: input }; onItemAdd : eventHandler('onItemAdd') });
The selectize() function returns the corresponding object, so you can get the list of options from it. How you access this value depends on your code structure, of course.
Something like the following should do the trick:
var selectize = $('#cbselect').get(0).selectize;
var current = selectize.getValue();
var option = selectize.options[ current ];
var mydata = option['hiddenname'];
That's assuming a single-select; for a multi-select getValue() will return an array of values which you will need to iterate over.
@mcavalletto thanks, it works fine
@mcavalletto I have multiple selectized combo boxes. Is it possible to get the corresponding element in the event and set the selectize value?
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days