Jquery回调脚本执行但不起作用
我从堆栈溢出中得到了很多帮助,让这个页面达到了它的功能,并且它几乎已经完成了,我只是不是 jQuery 专家。工作示例:
http://www.metropoliscreative.com/jake_test/test1.html
我我正在使用 Galleriffic(一个动态画廊 jQuery 插件)和 Quicksand(一个 jQuery 过滤插件)。
如果单击缩略图,它们将在大窗格中正确加载。如果您选择项目类型或行业,它将根据某些数据类型对这些缩略图进行排序。
然而,问题是一旦你对它们进行排序,Galleriffic 功能就会停止工作。因此,为了纠正这个问题,我在流沙初始化中包装了另一个画廊调用。因此,一旦流沙完成,它就会重置画廊。
然而,此时我收到了来自 galleriffic 的错误,我不知道为什么。我调用的方式与页面加载时调用的方式完全相同,然后它就可以工作了。
I've had a lot of help from stack overflow getting this page to where it is with its functionality and it's almost there, I'm just not a jQuery expert. Working example:
http://www.metropoliscreative.com/jake_test/test1.html
I'm using Galleriffic (a dynamic gallery jQuery plug) and Quicksand (a jQuery filtering plug).
If you click the thumbnails, they will load properly in the big pane. If you select project type or industry, it will sort those thumbnails based on some data types.
However, the issue is that once you sort them, the Galleriffic functionality stops working. So to correct this, I wrapped another galleriffic call within the quicksand initialization. So that once quicksand completes, it resets galleriffic.
However, I'm getting an error from galleriffic at this point and I'm not sure why. I'm calling the exact same way it is being called when the page loads and it works then.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于您的第二次
.galleriffic()
调用,它似乎引发了错误。我收到的错误是无法将“imageData”转换为对象
。这似乎是因为当您切换到(例如)项目类型 -> 时Brochure Packages,gallerific
尝试根据数据属性将当前图像 id 设置为 0。然而,似乎quicksand
搞砸了数据数组,导致gallerific
在第二次调用时看不到任何元素(也称为图像)。我认为quicksand
导致了问题,可能是因为它没有正确删除/添加图像。如果你看看 this 示例,删除图像的代码如下:然而,似乎
quicksand
只是使用.remove()
来删除图像。现在,我查看了removeImageByIndex()
的代码,似乎gallerific
保留了有关其使用的图像信息的缓存,这些信息在. remove()
由quicksand
调用。太棒了; Quicksand 错误地删除了图像,并且 galleryerific 没有更新到更改。
如何修复它?好吧,一种选择是尝试重写流沙脚本的删除和添加部分,以了解画廊。另一种方法是将流沙的删除部分重写为仅隐藏元素而不是删除它们(即设置
display:none;
而不是.remove()
)。我希望这会有所帮助,这就是我能想到的全部。
It seems to be throwing an error because of your second
.galleriffic()
call. The error I get isCannot convert 'imageData' to object
. This appears to be because when you switch to (for example) Project Type -> Brochure Packages,gallerific
tries to set the current image id to 0 based on the data attributes. However, it seems as thoughquicksand
screws up the data array which causesgallerific
to not see any elements (aka the images) on the second call. I think thatquicksand
is causing the issues, perhaps because it's not removing/adding the images properly. If you look at this example, the code for removing images is like this:It seems, however, that
quicksand
just uses.remove()
to get rid of the images. Now, I looked into the code forremoveImageByIndex()
and it seems thatgallerific
keeps a cache of information about the images it uses which does NOT get updated when.remove()
gets called byquicksand
.tldr; Quicksand removes the images incorrectly and gallerific doesn't get updated to the changes.
How to fix it? Well, one option would be to try and rewrite the removal and addition parts of your quicksand script to be aware of gallerific. Another one would be to rewrite the removal parts of quicksand to only HIDE elements rather than remove them (ie. set
display:none;
instead of.remove()
).I hope this helps, that's about all I can come up with.
当我查看您页面的源代码时,我在第 295 行(就在问题区域之前)看到了一个不应该出现的“d”。也许这就是你的代码没有被执行的原因。
When I looked at the source of your page, I saw a 'd' on line 295 (just before the problem zone) that shouldn't be there. Maybe that's the reason, your code doesn't get executed.