Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 未捕获类型错误:$(…).lightGallery(…).destroy不是函数_Jquery_Lightgallery - Fatal编程技术网

Jquery 未捕获类型错误:$(…).lightGallery(…).destroy不是函数

Jquery 未捕获类型错误:$(…).lightGallery(…).destroy不是函数,jquery,lightgallery,Jquery,Lightgallery,我正在网站上使用light gallery插件,同时运行 $('#categoryImages').lightGallery().destroy(true) 我得到了控制台错误 未捕获类型错误:$(…).lightGallery(…).destroy不是函数 下面提到的代码片段是我在light gallery中使用的网站代码 $subcategory) { $subcategoryImage= scandir($dir.strtolower($getCategory)."/".$subc

我正在网站上使用light gallery插件,同时运行
$('#categoryImages').lightGallery().destroy(true)

我得到了控制台错误

未捕获类型错误:$(…).lightGallery(…).destroy不是函数

下面提到的代码片段是我在light gallery中使用的网站代码

    $subcategory) { $subcategoryImage= scandir($dir.strtolower($getCategory)."/".$subcategory); unset($subcategoryImage[array_search('.', $subcategoryImage, true)]); unset($subcategoryImage[array_search('..', $subcategoryImage, true)]); foreach ($subcategoryImage as $key => $value2) { $data['subcategoryImages'][]= $dir.strtolower($getCategory)."/".$subcategory."/".$value2;?>
<li class="col-xs-6 col-sm-4 col-md-3" data-responsive=" 375, 480," data-src="">

<img class="img-responsive" src="">

作为文档,它应该是这样的:


更新fiddle:

作为文档,它应该是这样的:


更新fiddle:

您需要保存对已初始化插件的引用,然后在ajax完成后调用destroy,在调用destroy后重新初始化插件

var gal = $('#categoryImages');
gal.lightGallery();
/...
request.done(function(data) {
//...
$('.ajxcategoryImages').html(subcategoryImages1); //append the results 
  gal.data('lightGallery').destroy(true);//destroy the current gallery
  gal.lightGallery();//create a new one
/..

您需要保存对已初始化插件的引用,然后在ajax完成后调用destroy,在调用destroy后重新初始化插件

var gal = $('#categoryImages');
gal.lightGallery();
/...
request.done(function(data) {
//...
$('.ajxcategoryImages').html(subcategoryImages1); //append the results 
  gal.data('lightGallery').destroy(true);//destroy the current gallery
  gal.lightGallery();//create a new one
/..

感谢您的回复,我使用了您共享的“未捕获类型错误:gal.destroy不是函数”请提交您的完整代码,也许我可以帮助您Hi Jagjeet Singh:谢谢您的回复。我已经在我的网站上使用了light gallery,初始页面加载工作正常,点击多个复选框使用ajax获取与类别相关的图像。如果我选择了多个类别,灯光库将不工作。但是它不会在控制台中显示任何错误。不要在这里提交代码,请提供fiddle Hi Jagjeet Singh:jsfiddle.net/gireesht14/n5w7eoxh此链接将打开我的代码,但它与动态php代码相关,包括感谢您的回复,我使用了您共享的“Uncaught TypeError:gal.destroy不是一个函数”请用小提琴提交您的完整代码,也许我可以帮您Hi Jagjeet Singh:谢谢您的回复。我已经在我的网站上使用了light gallery,初始页面加载工作正常,点击多个复选框使用ajax获取与类别相关的图像。如果我选择了多个类别,灯光库将不工作。但是它不会在控制台中显示任何错误。不要在这里提交代码,请提供fiddle Hi Jagjeet Singh:jsfiddle.net/gireesht14/n5w7eoxh此链接将打开我的代码,但它与动态php代码相关,包括请参见下面的我的答案请参见下面的我的答案
var gal = $('#categoryImages');
gal.lightGallery();
/...
request.done(function(data) {
//...
$('.ajxcategoryImages').html(subcategoryImages1); //append the results 
  gal.data('lightGallery').destroy(true);//destroy the current gallery
  gal.lightGallery();//create a new one
/..