0
我在我的網頁上有一個datatables表格,裏面有多頁的分頁數據。每the example given by datatables,我用下面的JavaScript/jQuery的提交形式:
<script>
var oTable;
$(document).ready(function() {
$('#form').submit(function() {
var sData = oTable.$('input').serialize();
$.post('', sData); // WORKS
// $.post('', sData, $('body').html(data)); // DOES NOT WORK
return false;
});
oTable = $('#meters').dataTable();
});
</script>
當我通過$.post('', sData);
後,我所有的錶行張貼。當我發佈$.post('', sData, $('body').html(data));
時,只會發佈表格的可見頁面的行。爲什麼?
我是相當新的jQuery的 - 也許我失去了一些東西......
這裏是我用來初始化表的代碼:
<script>
/* Create an array with the values of all the input boxes in a column */
$.fn.dataTableExt.afnSortData['dom-text'] = function (oSettings, iColumn)
{
var aData = [];
$('td:eq('+iColumn+') input:last', oSettings.oApi._fnGetTrNodes(oSettings)).each(function() {
aData.push(this.value);
});
return aData;
}
/* Create an array with the values of all the select options in a column */
$.fn.dataTableExt.afnSortData['dom-select'] = function (oSettings, iColumn)
{
var aData = [];
$('td:eq('+iColumn+') select:last', oSettings.oApi._fnGetTrNodes(oSettings)).each(function() {
aData.push($(this).val());
});
return aData;
}
/* Create an array with the values of all the checkboxes in a column */
$.fn.dataTableExt.afnSortData['dom-checkbox'] = function (oSettings, iColumn)
{
var aData = [];
$('td:eq('+iColumn+') input:last', oSettings.oApi._fnGetTrNodes(oSettings)).each(function() {
aData.push(this.checked==true ? "1" : "0");
});
return aData;
}
$(document).ready(function() {
$('#meters').dataTable(
{
"aoColumns": [
{ "sSortDataType": "dom-text" },
{ "sSortDataType": "dom-select" },
{ "sSortDataType": "dom-checkbox" },
],
"aoColumnDefs": [
{
"aTargets": ["vbNoSearchSort"],
"bSearchable": false,
"bSortable": false
}
],
"bProcessing" :true,
"bStateSave" :true,
"sPaginationType": "full_numbers"
}
);
});
</script>
你有問題嗎? =) – rakslice