You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

46 lines
1.1 KiB

$(document).ready(function(){
//$('#id_city').attr('disabled', true)
$('select').select2({
width: 'element',
allowClear: true
});//end select
$('#id_city').select2({
placeholder: "Search city",
width: 'element',
ajax: {
url: "/admin/city/search/",
dataType: "json",
quietMillis: 200,
data: function(term, page, country){
var country = $('#id_country').val()
return {term: term,
page: page,
country: country};
},
results: function (data) {
var results = [];
$.each(data, function(index, item){
results.push({
id: item.id,
text: item.label
});
});
return {results: results};
}
},
initSelection : function(element, callback) {
var id= $(element).val();
var text = $(element).attr('data-init-text');
callback({id: id, text:text});
}
});
})//end ready