jquery-dzyables中的jquery-lazyload图像 [英] jquery-lazyload images in jquery-databables
问题描述
使用 datatables javascript插件,我想在分页表格中显示10k个小图片。
因为我加载了太多,我得到错误。
With the datatables javascript plugin I want to display 10k little images in a table with pagination.
Because I load too much of them, I get errors.
我想只在它们出现时才加载这些图像所以我找到了 lazyload插件。
I would like to load those images only when they appear so I found the lazyload plugin.
但是,图像最初根本不显示。
我必须手动输入
However, the images don't appear at all at first.
I have to manually enter
$("img.lazy").lazyload();
。
然后只加载打开的图像屏幕
(即当我向下滚动时,我看到所有其他图像都已卸载)。
这至少证明该插件有点工作。
in the browser console.
Then only it loads the images that are on screen
(i.e. when I scroll down, I see all other images unloaded).
This proves at least that the plugin is somewhat working.
使用数据表有什么特别之处吗?
我是否必须每秒脚本地触发延迟加载?
Is there something particular to do with the use of datatables?
Do I have to scriptually trigger lazyload every second?
谢谢!
推荐答案
我找到了另一种方法这里没有lazyload插件。
使用选项
I found another method here without the lazyload plugin.
Use the option
"fnRowCallback": customFnRowCallback
然后这个函数将用图像标记替换第一列。
and then this function will replace the first column with an image tag.
function customFnRowCallback( nRow, aData, iDisplayIndex )
{
$('td:eq(0)', nRow).html( '<img class="" src="http://aaaaa/'+ aData.attribute+'" alt="" />' );
return nRow;
}
这篇关于jquery-dzyables中的jquery-lazyload图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!