私はtablesorter
(http://tablesorter.com/docs/)をAJAXページャ機能と併用しています。プラグインを初期化するために使用するコードは次のとおりです。jQuery tablesorterが間違ったページから始まる
$(".track-grid table.tablesorter")
.tablesorter({
widthFixed: false,
cssChildRow: 'infoRow',
widgets: ['zebra']
})
.tablesorterPager({
container: $(".pager"),
ajaxUrl : 'analyse/getEvents?page={page}&size=10&totalCount='+totalCount,
customAjaxUrl: function(table, url) {
// get current selection & add it to the url
return url += '&filter=' + JSON.stringify(filter);
},
ajaxProcessing: function(data){
$('#tablesorter tbody').html(data.result.eventsHtml);
return [ parseInt(data.result.totalEventsCount) ];
},
page: 0,
processAjaxOnInit: true,
output: '{startRow} to {endRow} ({totalRows})',
updateArrows: true,
fixedHeight: false,
removeRows: false,
cssNext : '.next', // next page arrow
cssPrev : '.prev', // previous page arrow
cssFirst : '.first', // go to first page arrow
cssLast : '.last', // go to last page arrow
cssGoto : '.gotoPage', // page select dropdown - select dropdown that set the "page" option
cssPageDisplay : '.pagedisplay', // location of where the "output" is displayed
cssPageSize : '.pagesize', // page size selector - select dropdown that sets the "size" option
cssDisabled : 'disabled', // Note there is no period "." in front of this class name
cssErrorRow : 'tablesorter-errorRow' // error information row
});
これはすべてうまくいきます。イベントは初期化され(バックエンドからフェッチされます)、クリックするたびに新しいイベントがロードされます。しかし、このページは、ユーザーが最後に自分のアカウントにログインしたときに「記憶」しているようです。たとえば、ページャをページ1(0)から始めたのですが、ページ数を2回切り替えてからnodeJSサーバーを再起動した場合は、ブラウザにログインして、ページは私が手動で設定した最後のものです。ページャが常に最初のページから起動するようにするにはどうすればよいですか? (ページ更新時にも)また、ページサイズは25になるように表示されていますが、初期化時に10に設定されていますが、これはどこが間違っていますか?
ありがとうございます!
ありがとうございました。それは本当に私の問題を解決しました!私は自分自身に、どのようにして "サイズ"の問題を修正したのか説明することはできません。つまり、以前はどのページを保存していないのですが、ページのサイズは25から10にどのように影響しますか?ありがとう! –
'selected'属性でページャーサイズオプションのいずれかを設定すると、初期設定よりも優先されます。 – Mottie