50 lines
1.4 KiB
HTML
50 lines
1.4 KiB
HTML
<form method="post" action="/companyinfo/" id="companyform">
|
||
{% csrf_token %}
|
||
{{ companyinfo.non_field_errors }}
|
||
<table class="detailtable" style="margin:10px">
|
||
<thead>
|
||
<tr>
|
||
<th style="width:50%">
|
||
属性
|
||
</th>
|
||
<th style="width:50%">
|
||
内容
|
||
</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{% for field in companyinfo %}
|
||
<tr>
|
||
<td> {{ field.label_tag }}</td>
|
||
<td>{{ field }}{{ field.errors }}</td>
|
||
</tr>
|
||
{% endfor %}
|
||
<tr>
|
||
<td colspan="2"><button type="button" class="btn btn-primary float-right" onclick="submitForm()">提交</button></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</form>
|
||
<script>
|
||
function submitForm() {
|
||
// jquery 表单提交
|
||
$("#companyform").ajaxSubmit(function(result) {
|
||
// 对于表单提交成功后处理,result为表单正常提交后返回的内容
|
||
if (result.code == 1) {
|
||
$.messager.show({
|
||
msg:'保存成功',
|
||
timeout:1000,
|
||
showType:'slide'
|
||
});
|
||
}else{
|
||
$.messager.show({
|
||
msg:'保存失败',
|
||
timeout:1000,
|
||
showType:'slide'
|
||
});
|
||
}
|
||
});
|
||
return false; // 必须返回false,否则表单会自己再做一次提交操作,并且页面跳转
|
||
}</script>
|
||
|