当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - How can I have a close button to close the expanded item on isotope layout complete

问题描述:

I have modified the isotope layout complete event so that the when you click on an item, it expands and when you click on another item, the other item will get smaller again. It works fine but I want to put a close button to the expanded item so that you can make that item smaller again.

here's the code that I modified. I added the $(.item).removeClass('gigante'); from the original Isotope documentation.

 $container.on( 'click', '.item', function() {

$('.item').removeClass('gigante');

$( this ).toggleClass('gigante');

$container.isotope('layout');

});

Here is my fiddle with a close button that doesn't work.

http://jsfiddle.net/vanduzled/D26nG/

I don't mind if you click on the expaned div.item, it closes. I just want some other way to close it other than click some other item.

网友答案:

You have to bind a function to the close element, and prevent the event from propagating. E.g., add this below your "$container.on( 'click', '.item', function() {" ...

    $container.on('click', '.close', function () {
        $('.item').removeClass('gigante');
        $container.isotope('layout');
        return false;
    });
分享给朋友:
您可能感兴趣的文章:
随机阅读: