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.
93 lines
2.4 KiB
93 lines
2.4 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});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
//
|
|
$('#id_tag').select2({
|
|
placeholder: "Search tag",
|
|
width: '550px',
|
|
multiple: true,
|
|
ajax: {
|
|
|
|
url: "/admin/theme/tag/search/",
|
|
dataType: "json",
|
|
quietMillis: 200,
|
|
multiple: true,
|
|
|
|
data: function(term, page, theme){
|
|
var theme = $('#id_theme').serialize();
|
|
return {term: term,
|
|
page: page,
|
|
theme: theme};
|
|
},
|
|
|
|
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 data = [];
|
|
$(element.val().split(",")).each(function(i) {
|
|
var item = this.split(':');
|
|
data.push({
|
|
id: item[0],
|
|
text: item[1]
|
|
});
|
|
});
|
|
callback(data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})//end ready
|
|
|