【发布时间】:2011-05-03 15:59:10
【问题描述】:
我有一个包含 100 多张图片的图库,为了使其加载速度更快,我想将其分成 30 组。页面上有一个导航“图库 1 2 3 4 5”,当用户点击任何我想将链接的href加载到“#rCol”的数字中 - 但只有“#galleria”部分。我可以让它加载内容,但它 A)加载整个页面,B)“画廊”功能未启用。
是否可以制作一个包含所有图像的 xml 文件并创建一个一次可以跳过 30 个图像的寻呼机?
我正在尝试从链接的 href 中创建一个 var,因此我不必为每个类添加一个类并为每个类编写一个函数。
$("ul#gallery li a").live('click',function(e) {
e.preventDefault();
var $parent = $(this).parent();
$parent.addClass("selected").siblings().removeClass("selected");
var href = $(this).attr('href');
$("#rCol").load(href, function() {
$("#galleria").galleria();
});
});
// Initialize Galleria
$("#galleria").galleria({
transition: 'fade',
width: 800,
height: 536,
extend: function(options) {
Galleria.log(this) // the gallery instance
Galleria.log(options) // the gallery options
// listen to when an image is shown
this.bind('image', function(e) {
Galleria.log(e) // the event object may contain custom objects, in this case the main image
Galleria.log(e.imageTarget) // the current image
// lets make galleria open a lightbox when clicking the main image:
$(e.imageTarget).click(this.proxy(function() {
this.openLightbox();
}));
});
}
});
有什么想法吗?
尝试重新初始化“galleria”函数here。各种问题,不更新缩略图,然后单击专辑 2 后,返回专辑 1 它将整个页面加载到 div 中。
$("ul#gallery li a").live('click',function(e) {
e.preventDefault();
var $parent = $(this).parent();
$parent.addClass("selected").siblings().removeClass("selected");
var href = $(this).attr('href');
$("#rCol").load(href, function() {
$("#galleria").galleria({
transition: 'fade',
width: 800,
height: 536,
extend: function(options) {
Galleria.log(this) // the gallery instance
Galleria.log(options) // the gallery options
// listen to when an image is shown
this.bind('image', function(e) {
Galleria.log(e) // the event object may contain custom objects, in this case the main image
Galleria.log(e.imageTarget) // the current image
// lets make galleria open a lightbox when clicking the main image:
$(e.imageTarget).click(this.proxy(function() {
this.openLightbox();
}));
});
}
});
});
});
【问题讨论】:
-
“加载整个页面”是指包括
<html>和<body>和</body>?那会让它变得有趣。您能否发布指向整个 HTML 响应的链接?在 JS 中你可能只需要 2 个response.split。 (讨厌,但可能。) -
附言。
.live确实只适用于<A>点击事件而不适用于 Galleria 插件,但您可以重新初始化它,没问题。 -
@Rudie,请参阅上面编辑过的评论,了解我尝试重新初始化图库功能。谢谢你。
-
这不是我的想法。我会用简单的(半伪=))html + js来回答。