jquery-selectize.js changed dropdown identification issue-Collection of common programming errors
I did it like that. It works but I hope this is a good way for doing this.
var xhr , a;
var country, $country;
var city, $city;
$country = $(".select2-country").selectize({
render: {
option: function(item, escape) {
var markup = "";
if (item.value !== undefined && item.value != 0) {
markup += ' ';
}
markup += item.text;
markup += '';
return markup;
}
},
onChange: function(value) {
city = $(this.$dropdown).parent().siblings('.select2-city')[0].selectize;
if (!value.length){city.clearOptions(); return;};
city.disable();
city.clearOptions();
city.load(function(callback) {
xhr && xhr.abort();
xhr = $.ajax({
url: draSite + '?index.php&option=com_dratransport&view=',
dataType: 'json',
data:{
selected: value,
task: 'getCities',
},
success: function(results) {
city.enable();
callback(results);
},
error: function() {
callback();
}
});
});
},
});
$city = $('.select2-city').selectize({
valueField: 'value',
labelField: 'text',
searchField: ['text'],
sortField: 'sort',
sortDirection: 'ASC',
diacritics:true,
});
for(var i = 0; i