bwl*_*lee 5 hidden field submit x-editable
在X-editable的文档中,我们可以创建一个新记录,但是如何编辑现有记录,并将其名称和电子邮件字段以及它的id = 1(此ID未更改)发布到后端?
<table>
<thead><th>id</th><th>name</th><td>email</th></thead>
<tbody?
<tr><td><span>1</span></td><td><span class='myeditable'>name</span></td><td><span class='myeditable'>email@example.com</span></td></tr>
</tbody>
</table>
$('.myeditable').editable({
type: input,
url: '/edituser'
});
$('#save-btn').click(function() {
$('.myeditable').editable('submit', {
url: '/edituser',
ajaxOptions: {
dataType: 'json' //assuming json response
},
success: function(data, config) {
if(data && data.id) { //record created, response like {"id": 2}
},
error: function(errors) {
}
});
});
Run Code Online (Sandbox Code Playgroud)
我使用 Angular-xeditable 来做到这一点,但我认为想法是一样的。
我在表中添加了一个隐藏的跨度,并给了它一个电子名称。ng-show 设置 display:none ,我认为这正是您需要做的。
<span
editable-text="journalEntry._id"
e-name="_id"
e-form="rowform"
ng-show="false">
</span>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1858 次 |
| 最近记录: |