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.
 
 
 
 
 
 

47 lines
1.3 KiB

function make_event_select(id, url, placeholder){
$(id).select2({
placeholder: placeholder,
multiple: true,
ajax: {
url: url,
width: '550px',
dataType: "json",
quietMillis: 200,
multiple: true,
data: function(term, page, theme){
return {term: term,
page: page};
},
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);
}
});
}
$(document).ready(function(){
make_event_select('#id_expositions', '/admin/exposition/search/', 'Выставки');
make_event_select('#id_conferences', '/admin/conference/search/', 'Конференции');
});