我们同时使用两个脚本:prettyPhoto和jQuery分页。当页面第一次加载时,这两个脚本都正常工作。但是,当我单击分页的第2页时,灯箱将不再显示,但我仍然可以从一个页面转到另一个页面。这两个脚本都是初始化脚本:
jQuery分页:
<script type="text/javascript">
// This is a very simple demo that shows how a range of elements can
// be paginated.
// The elements that will be displayed are in a hidden DIV and are
// cloned for display. The elements are static, there are no Ajax
// calls involved.
/**
* 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 = jQuery('#hiddenresult div.result:eq('+page_index+')').clone();
$('#Searchresult').empty().append(new_content);
return false;
}
/**
* Initialisation function for pagination
*/
function initPagination() {
// count entries inside the hidden content
var num_entries = jQuery('#hiddenresult div.result').length;
// Create content inside pagination element
$("#Pagination").pagination(num_entries, {
callback: pageselectCallback,
items_per_page:1 // Show only one item per page
});
}
// When document is ready, initialize pagination
$(document).ready(function(){
initPagination();
});
</script>
prettyPhoto:
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$("a[rel^='prettyPhoto']").prettyPhoto();
});
</script>
有人知道冲突在哪里吗?谢谢。
发布于 2011-07-07 22:39:37
我找到了解决我的问题的方法(我在另一个论坛上找到了):
我只需要插入$(“rel^=‘prettyPhoto’”).prettyPhoto();在函数pageselectCallback中插入如下所示:
function pageselectCallback(page_index, jq){
var new_content = jQuery('#hiddenresult div.result:eq('+page_index+')').clone();
$('#Searchresult').empty().append(new_content);
$("a[rel^='prettyPhoto']").prettyPhoto();
return false;
}
如果我能把+1给回答它的人,这里。:)
发布于 2011-07-07 20:34:29
尝试使用Jquery .delegate()
$("a").delegate("[rel^='prettyPhoto']", "load", function()
{
$("a[rel^='prettyPhoto']").prettyPhoto();
});
https://stackoverflow.com/questions/6619888
复制相似问题