【发布时间】:2011-02-04 03:37:59
【问题描述】:
根据JQuery pagination plugin's文档中回调的定义。它似乎只获取自己的两个参数。那么,我怎样才能将额外的参数传递给回调函数。
回调
一个被调用的回调函数 当用户点击分页时 关联。该函数接收两个 参数:新页面索引和 分页容器(一个 DOM 元素)。 如果回调返回 false,则 事件传播停止。默认 值:函数(){返回假;}。这 回调函数是必不可少的 分页功能!它 应该包含更新您的代码 内容。快速的用户体验 你不应该通过 AJAX 加载内容 在这个函数中。相反,预加载 一些内容页面并在它们之间切换 他们用这个功能。
例如插件使用代码[来自其演示]:
附加分页插件:
$("#News-Pagination").pagination(122, {
items_per_page:20,
callback:pageselectCallback
});
回调函数:
/**
* Callback function that displays the content.
*
* Gets called every time the user clicks on a pagination link.
*
* @param {int}page_index New Page index
* @param {jQuery} jq the container with the pagination links
* as a jQuery object
*/
function pageselectCallback(page_index, jq){
var new_content
= $('#hiddenresult div.result:eq(' + page_index + ')').clone();
$('#Searchresult').empty().append(new_content);
return false;
}
非常感谢!!
【问题讨论】:
标签: jquery pagination