我试图使用 Colorbox
来拍摄来自Facebook的照片, 这对在页面上显示的图像效果很好。 但是当我使用 < code>.getJSON 来加载25个以上的图像并将其附加到我的表格上时, 颜色框不再有效。 我看到有人提到使用 < code>. live 命令, 但我猜我没注意要做什么...
这是我的密码
$(function () {
$(".photos1").colorbox({
rel: photos1 ,
transition: "fade"
});
var loading = <img src="images/ajax-loader.gif" /> <b>LOADING</b> ;
$( #get_albums ).click(function () {
$( #ld_ck ).html(loading);
$( #get_albums ).html( );
load_albums();
});
$( #get_photos ).click(function () {
$( #ld_ck ).html(loading);
$( #get_photos ).html( );
load_photos();
});
function load_photos() {
var after = $( #photos_next ).val();
var offset = $( #photos_offset ).val();
var gallery_id = $( #g_id ).val();
$.getJSON( get_photos.php?gallery_id= + gallery_id + &after= + after + &offset= + offset, function (json) {
$.each(json, function (key, val) {
if (key == "photos") {
$( #photos ).append(val);
}
if (key == "after") {
$( #photos_next ).val(val);
}
if (key == "offset") {
$( #photos_offset ).val(val);
}
if (key == "count") {
if (val == "25") {
$( #get_photos ).html( <b>SEE MORE</b> );
}
}
});
$( #ld_ck ).html( );
});
}
});
get_photos.php
返回到 jquery 的表格行的 json
字符串 。
这里仅是基 html 表格的一行, 但初始有 5 行, 初始有 5 行, 且 < code> get_ photos.php 一次又加上 5 。
<table width="99%" border="0" cellspacing="5" cellpadding="0" id="photos" class="photos">
<tr>
<td align="center" class="photos" style="padding-top:10px; height:140px; width:140px; border:1px solid #7B7B7B; background:#E9E9E9;"><a class="photos1" href="fb_photo.jpg"> <img src="fb_thumb.jpg" alt="fb_photo" border="0" /> </a> </td>
<td align="center" class="photos" style="padding-top:10px; height:140px; width:140px; border:1px solid #7B7B7B; background:#E9E9E9;"><a class="photos1" href="fb_photo.jpg"> <img src="fb_thumb.jpg" alt="fb_photo" border="0" /> </a> </td>
<td align="center" class="photos" style="padding-top:10px; height:140px; width:140px; border:1px solid #7B7B7B; background:#E9E9E9;"><a class="photos1" href="fb_photo.jpg"> <img src="fb_thumb.jpg" alt="fb_photo" border="0" /> </a> </td>
<td align="center" class="photos" style="padding-top:10px; height:140px; width:140px; border:1px solid #7B7B7B; background:#E9E9E9;"><a class="photos1" href="fb_photo.jpg"> <img src="fb_thumb.jpg" alt="fb_photo" border="0" /> </a> </td>
<td align="center" class="photos" style="padding-top:10px; height:140px; width:140px; border:1px solid #7B7B7B; background:#E9E9E9;"><a class="photos1" href="fb_photo.jpg"> <img src="fb_thumb.jpg" alt="fb_photo" border="0" /> </a> </td>
</tr>
</table>
<div style="width:99%; text-align:center;" id="see_more">
<input name="photos_next" id="photos_next" type="hidden" value="xxxxxxxxxxxx" />
<input name="photos_offset" id="photos_offset" type="hidden" value="25" />
<input name="g_id" id="g_id" type="hidden" value="xxxxxxxx" />
<a id="get_photos"><b>SEE MORE</b></a></div>
<div id="ld_ck" class="loader" style="width:99%; text-align:center;" ></div>