我得到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