【发布时间】:2013-07-11 08:31:32
【问题描述】:
在X-editable的文档中,我们可以新建一条记录,但是如何编辑一条已有的记录,并把它的name和email字段以及它的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) {
}
});
});
【问题讨论】:
标签: submit field hidden x-editable