<td>
<button class="edit" >开</button>
</td>
在HTML的页面写的是button,在js里面写了个开关自动切换,然后ajax把信息传递到后端去
$(function () {
$('.edit').click(function () {
var td = $(this);
var id = $(td).parent().parent().children('td').html();
var business = $(td).parent().parent().children('.business').html();
var html_edit = $(td).parent().children('.edit').html();
if (html_edit == '开'){
td.html('关');
$.ajax({
type: "post",
url: "notice_change",
data: { goods_id:id, business:business, notice:'关', csrf_token:$('#csrf_token').val()},
dataType: "application/x-www-form-urlencoded",
success: function(data){}
});
}
else if (html_edit == '关'){
td.html("开");
$.ajax({
type: "post",
url: "notice_change",
data: { goods_id:id, business:business, notice:'开', csrf_token:$('#csrf_token').val()},
dataType: "application/x-www-form-urlencoded",
success: function(data){}
});
}
});
});
在定义class的时候写的是下面这样
class NoticeChange(FlaskForm):
notice = StringField('', validators=[DataRequired()])
goods_id = StringField('', validators=[DataRequired()])
business = StringField('', validators=[DataRequired()])
但是后台的表单验证提示下面这个错:
<UnboundField(StringField, ('',), {'validators': [<wtforms.validators.DataRequired object at 0x0000000004745C18>]})>
这是为什么呀?我先一脸懵逼呀。。。
UnboundField 感觉像是后端view没有绑定form吧。
可以提供一下view层的代码吗