parent
a8b7ab3282
commit
0074d64068
44 changed files with 327 additions and 543 deletions
@ -1,94 +0,0 @@ |
|||||||
//replace
|
|
||||||
$(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
|
|
||||||
Loading…
Reference in new issue