0

I am using some nice plugins from jQuery for using AJAX based sites. Now I came to the problem that I would like to use livequery for specifying my slimbox. The problem is, that it doesn't get my groups as stated in the linkFiler function.

$(document).ready(function () 
{
    $('a[rel^="lightbox"]').livequery(function()
    {
        $(this).slimbox(null, function(el) // link mapper
        {
            return [el.href, el.title + '<br/><a href=\"' + el.href + '\">Download</a>'];
        }
        , function(el) // links filter
        {
            return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
        });
    });
});

What's going wrong? In one of my pages (Biography), the slimbox only works when I refresh the page on that site, but not when clicking through my pages. The groups aren't working in the Discography section of the site.

Parts of the bio and discography pictures are as follows:

<a href="albumCover.jpg" rel="lightbox-disco"><img src="albumCover_thumb.jpg" alt=""></a>

<a rel="lightbox" href="bandPic.png"><img style="float:right;margin-left:1em;" src="bandPic_thumb.png" alt=""></a>

Thanks in advance!

UPDATE

I found my problem in the slimbox code, because it uses the this to be its links. So everytime livequery is fired, the this is overwritten and should actually contain the full selector. Maybe I can solve this by just saying:

$('a[rel^="lightbox"]').livequery(function()
{
    $('a[rel^="lightbox"]').slimbox(null, function(el) // link mapper
...

But doing that would make livequery fire a lot of times towards slimbox, which is not wanted behaviour. Is there a nicer way to make it not fire so often?

UPDATE2

As for the other questio in the biography pages. livequery updates on removing the image, but all the other sites are done properly on adding the images... How strange...

4

1 回答 1

1

我实际上找到了解决方案,但这很奇怪。如果有人读到这篇文章并可以向我解释,那就太好了。不知何故,livequery 使我的代码在空<head>标签和填充标签之间有所不同。因此,当我的<style>子页面中有一个标签(例如 BIO 或 DISCO)时,即使它是空的,livequery 也会起作用。如果我有一个空<head>标签,则 livequery 仅适用于离开页面。这很奇怪。现在我刚刚创建了一个空<style>标签,每个页面都可以正常工作。

至于组问题,我的 livequery 有点不同,所以 livequery 不再被调用了。在我的 HTML 中,我确信<div class="content">每个子页面中总是有一个。所以我可以做一个实时查询,例如:

$('.content').livequery(function()
{
    $('a[rel^="lightbox"]').slimbox(null, function(el) // link mapper
...

slimbox 的问题在于,它只能将完整的选择器作为其作用域。因此,将 slimbox 更改为不同的选择器会禁用旧的选择器。在其代码中,它执行以下操作:

var links = this; // where this is the $(selector)
于 2011-01-08T23:41:21.843 回答