我得到xeditable
和select2
與api
調用作爲來源,一切都很好,除了以下內容。xeditable&select2下拉w/ajax源提交後顯示爲空
提交select2下拉菜單後,該表的值顯示爲EMPTY
,並且需要刷新頁面才能更新爲正確的值。
有誰知道如何將值更新爲選定的select2
下拉值?
我的html:
<td class="eo_role"><a href="#" data-pk={{r.pk}} data-type="select2" data-url="/api/entry/{{r.pk}}/"
data-name="eo_role" data-title="Enter EO_role">{{r.eo_role}}</a></td>
這裏是我的JS:
$('#example .eo_role a').editable({
params: function(params) { //params already contain `name`, `value` and `pk`
var data = {};
data[params.name] = params.value;
return data;
},
source: 'http://localhost:8000/api/eo_role/select_two_data/',
tpl: '<select></select>',
ajaxOptions: {
type: 'put'
},
select2: {
cacheDatasource:true,
width: '150px',
id: function(pk) {
return pk.id;
},
ajax: {
url: 'http://localhost:8000/api/eo_role/select_two_data/',
dataType: "json",
type: 'GET',
processResults: function(item) {return item;}
}
},
formatSelection: function (item) {
return item.text;
},
formatResult: function (item) {
return item.text;
},
templateResult: function (item) {
return item.text;
},
templateSelection : function (item) {
return item.text;
},
});
再次 - 一切正常(數據庫更新,下拉列表填充等),但是<td>
獲取與更新"EMPTY"
提交下拉後 - 要求刷新頁面以顯示正確的值。
我試過類似的問題/解決方案的鏈接,但沒有工作。 https://stackoverflow.com/questions/28190106/x-editable-putting-empty-after-successful-update – TangoAlee