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.
124 lines
3.2 KiB
124 lines
3.2 KiB
function handleTest(data){
|
|
if (data.success){
|
|
location.reload();
|
|
}
|
|
}
|
|
|
|
|
|
function formHandler(id, handleFunction){
|
|
$(id).on('submit', function(event){
|
|
event.preventDefault();
|
|
$this = $(this);
|
|
var url = $this.attr('action');
|
|
var formData = $this.serialize();
|
|
$.post(url, formData, handleFunction);
|
|
});
|
|
}
|
|
|
|
|
|
$(document).ready(function(){
|
|
|
|
formHandler('#home_form', handleTest);
|
|
formHandler('#name_form', handleTest);
|
|
formHandler('#spec_form', handleTest);
|
|
formHandler('#address_form', handleTest);
|
|
formHandler('#social_form', handleTest);
|
|
formHandler('#phone_form', handleTest);
|
|
formHandler('#email_form', handleTest);
|
|
formHandler('#web_page_form', handleTest);
|
|
formHandler('#found_form', handleTest);
|
|
formHandler('#staff_form', handleTest);
|
|
formHandler('#description_form', handleTest);
|
|
|
|
$('#id_country').select2({
|
|
width: 'element'
|
|
});
|
|
$('#id_city').select2({
|
|
placeholder: "Search city",
|
|
width: 'element',
|
|
ajax: {
|
|
|
|
url: "/city/get-city/",
|
|
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: "Выберите ключевые теги",
|
|
width: '368px',
|
|
multiple: true,
|
|
maximumSelectionSize: 5,
|
|
ajax: {
|
|
|
|
url: "/theme/get-tag/",
|
|
dataType: "json",
|
|
quietMillis: 200,
|
|
|
|
data: function(term, page, country){
|
|
var themes = $('#theme-inf').attr('data-theme');
|
|
themes = themes.split(',');
|
|
themes.pop();
|
|
|
|
return {term: term,
|
|
page: page,
|
|
themes: themes};
|
|
},
|
|
|
|
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);
|
|
*/
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}); |