【发布时间】:2016-10-11 10:29:22
【问题描述】:
我在我的 JSP 页面中使用了boostrap-table
<table id="mytable"
data-row-style="rowStyle" class="table table-hover" id="table-pagination "
data-url="lots.json"
data-toggle="table"
data-pagination="true"
data-show-pagination-switch="true"
data-sort-order="desc"
data-search="true"
data-show-refresh="true"
data-show-columns="true"
data-page-list="[10, 25, 50, 100, ALL]"
>
<thead>
<tr>
<th data-field="machine" data-align="center" data-sortable="true">machine</th>
<th data-field="mould" data-align="center" data-sortable="true">mould</th>
<th data-field="lot" data-editable="true" data-align="center" data-sortable="true">LOT</th>
</tr>
</thead>
</table>
我已经在我的第 3 列中插入了 editable method,它在前端可以工作。
我尝试捕捉我在表中插入的新值(例如,我编辑一行并插入“12”):我试过这个:
$(function() {
$('#mytable').on('editable-save.bs.table', function(field, row, oldValue, $el){
console.log("1 "+ field);
console.log("2 "+ row);
console.log("3 "+ oldValue);
console.log("4 "+ $el);
});
});
但在控制台中我得到:
1 [object Object]
2 lot
3 [object Object]
4 002400000 // this is the old one
【问题讨论】:
-
我认为这是可编辑的扩展选项。在这里您应该找到一个选项,当您完成编辑时会发生什么,并且在该回调中您需要向服务器端的脚本调用 ajax 请求:vitalets.github.io/x-editable/docs.html#editable
-
这将是那个方法:
onEditableSave(editable-save.bs.table)从这里:github.com/wenzhixin/bootstrap-table/tree/master/src/extensions/…
标签: javascript jquery twitter-bootstrap bootstrap-table