Jquery回调脚本执行但不起作用

发布于 2024-10-14 02:39:41 字数 525 浏览 5 评论 0原文

我从堆栈溢出中得到了很多帮助,让这个页面达到了它的功能,并且它几乎已经完成了,我只是不是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一百个冬季 2024-10-21 02:39:42

由于您的第二次 .galleriffic() 调用,它似乎引发了错误。我收到的错误是无法将“imageData”转换为对象。这似乎是因为当您切换到(例如)项目类型 -> 时Brochure Packages,gallerific 尝试根据数据属性将当前图像 id 设置为 0。然而,似乎 quicksand 搞砸了数据数组,导致 gallerific 在第二次调用时看不到任何元素(也称为图像)。我认为 quicksand 导致了问题,可能是因为它没有正确删除/添加图像。如果你看看 this 示例,删除图像的代码如下

$('#removeImageByIndexLink').click(function(e) {
    if (!gallery.removeImageByIndex(5))
        alert('There is no longer an image at position 5 to remove!');

    e.preventDefault();
});

:然而,似乎 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 is Cannot 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 though quicksand screws up the data array which causes gallerific to not see any elements (aka the images) on the second call. I think that quicksand 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:

$('#removeImageByIndexLink').click(function(e) {
    if (!gallery.removeImageByIndex(5))
        alert('There is no longer an image at position 5 to remove!');

    e.preventDefault();
});

It seems, however, that quicksand just uses .remove() to get rid of the images. Now, I looked into the code for removeImageByIndex() and it seems that gallerific keeps a cache of information about the images it uses which does NOT get updated when .remove() gets called by quicksand.

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.

染年凉城似染瑾 2024-10-21 02:39:41

当我查看您页面的源代码时,我在第 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文