Whoops - too many curly brackets in the toggle there. Correct code here:

$(".toggle_cat a").each(function(i){
        $(this).attr("title", "Click here to exclude this cat");
        $(this).click(function(event){
                $(this).toggleClass("selected");
        });
        var rel = this.rel;
        $(this).toggle(
                function() { $("." + rel).hide('slow'); },
                function() { $("." + rel).show('fast'); }
        );
});

On 05/04/2007, at 12:07 AM, Joel Birch wrote:

What about this (using your coding style to avoid confusion):

$(".toggle_cat a").each(function(i){
        $(this).attr("title", "Click here to exclude this cat");
        $(this).click(function(event){
                $(this).toggleClass("selected");
        });
        var rel = this.rel;
        $(this).toggle({
                function() { $("." + rel).hide('slow'); },
                function() { $("." + rel).show('fast'); }
        });
});

It occurred to me that your previous code is actually merely applying toggle behaviour to other elements when you click a link, not actually running the functions in the toggle, which you may actually want to do. The reason why the simple toggle() worked then would be because toggle has different behaviour depending on whether you pass in functions to it or not.

Does this help?

Joel.

Reply via email to