Hi, I want to know if is possible to implement some way to get raw data of the currently selected object, I mean a jQuery object with all the information of the item.
Currently there is getItem (), but it returns the jQuery element, not the data.
Do you mean the raw data? If so, give this a try:
var $select = $('select').selectize({ ... });
var selectize = $select[0].selectize;
var selected_objects = $.map(selectize.items, function(value) {
return selectize.options[value];
});
It worked, thank you :)
This is how I get and use the "raw" data that is bound to the selected option;
$('#search').selectize({
onItemAdd: function (value, $item) {
var data = this.options[value];
if (data && data.Url) {
window.location.href = data.Url;
}
}
});
An enhancement proposal is currently being considered at #1085
you can get all user events from onInitialize 馃憤
$('select').selectize({
onInitialize: function (selectize) {
selectize.on('change', function (value) {
var elem = this.$input[0];
console.log('on "change" event fired > ' + elem.id);
});
selectize.on('focus', function () {
console.log('on "focus" event fired');
});
selectize.on('dropdown_open', function () {
console.log('on "dropdown_open" event fired');
});
}
}
Most helpful comment
Do you mean the raw data? If so, give this a try: