我正在努力创建一个有效的xditable select2字段。
代码如下:
<a href="#" data-pk="" class="uassignment" id="uassignment" name="uassignment" aria-describedby="basic-addon2"></a>
使用Javascript:
var source = [
{id: 'A', text: 'A'},
{id: 'B', text: 'B'}
];
$('#uassignment').editable({ //to keep track of selected values in multi select
name: 'assignment',
inputclass: 'some_class',
showSearchBox: false,
type: 'select2',
url: '/myurl/assignmentupdate/',
source : source ,
params: function(params) {
params.pk = $("#updateid").val();
return params;
},
title: 'Assignment',
select2: {
multiple : true,
emptytext: 'None',
minimumResultsForSearch: -1
}
});
此代码在浏览器端正常运行。但是,当我尝试在服务器上检索所选值时,它返回空列表。 (在Django View中)
assignment_list = request.POST.getlist('value')
print(assignment_list) //This statement returns empty list
assignment_list = ','.join(assignment_list)
temp.assignment = assignment_list
请帮我解决这个问题。