PLease我需要你的帮助,我试图用jeditable编辑{%for%}中的表格中的一个字段。django jeditable不工作
编辑DIV:
<td><div class="edit" id="{{ c.id }}">{{ c.name|safe }}</div></td>
jeditable代码:
<script>
$(document).ready(function(){
$('.edit').editable('/categoryedit/{{ c.id }}/', {
style: 'display: inline'
});
});
</script>
地址:
url(r'^categoryedit/(?P<id>\d+)/$', 'pos.views.CategoryEdit'),
查看:
def CategoryEdit(request, category_id):
id = request.POST.get('category_id', '')
value = request.POST.get('value', '')
categoria = Category.objects.get(pk=id)
categoria.name = value
categoria.save()
return HttpResponse(escape(value))
你的具体问题是什么?不只是“不工作”。 – deadly
该字段变得可编辑,但不保存对数据库的更改,并且当字段丢失焦点时也丢失更改。 – rpalma