Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7657989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:08:35+00:00 2026-05-31T13:08:35+00:00

so i’m playing around with jquery isotope and trying to combine two options into

  • 0

so i’m playing around with jquery isotope and trying to combine two options into one button

I have one set of links which filters the results, the other set of links changes the layout mode. I would like filter links to change the layout as well as filtering.

heres the spine documentation which is the layout mode i’m changing to from default.

i think the problem lies with the data-option-key, as one is set to filter and the other to layoutMode, is it possible to have two different data-option-key’s with different kinds of data-option-values within?

here’s the html followed by the script:

<section id="options">    
    <ul id="filters" class="option-set clearfix" data-option-key="filter">
        <li><a href="#filter" data-option-value="*:not(.before)" class="selected">everything</a></li>
        <li><a href="#filter" data-option-value=".modern">modern</a></li>
        <li><a href="#filter" data-option-value=".traditional">traditional</a></li>
        <li><a href="#filter" data-option-value=".commercial">commercial</a></li>
        <li><a href="#filter" data-option-value=".automotive">automotive</a></li>
        <li><a href="#filter" data-option-value=".bespoke">bespoke</a></li>
        <li><a href="#filter" data-option-value=".before, .after">before <span style="font-size:10px;">&</span> after</a></li>
    </ul>

    <ul id="layouts" class="option-set clearfix" data-option-key="layoutMode">
        <li><a href="#filter" data-option-value="masonry" class="selected">normal</a></li>
        <li><a href="#filter" data-option-value="spineAlign">spine</a></li>
    </ul>
</section> <!-- # O P T I O N S -->


<div id="result"></div>
<div id="container" class="clickable clearfix">
    <div class="element portrait before">
        <a href="img/gallery/large/beforeandafter/image1_before.jpg" rel="shadowbox[traditional]"><img src="img/gallery/thumbs/beforeandafter/image1_before.jpg" alt="chair" /></a>
    </div>
    <div class="element portrait after bespoke">
        <a href="img/gallery/large/beforeandafter/image1_after.jpg" rel="shadowbox[traditional]"><img src="img/gallery/thumbs/beforeandafter/image1_after.jpg" alt="chair" /></a>
    </div>
    <div class="element portrait modern">
        <a href="img/gallery/large/modern/image1.jpg" rel="shadowbox[traditional]"><img src="img/gallery/thumbs/modern/image1.jpg" alt="chair" /></a>
    </div>
    <div class="element landscape modern">
        <a href="img/gallery/large/modern/image2.jpg" rel="shadowbox[traditional]"><img src="img/gallery/thumbs/modern/image2.jpg" alt="chair" /></a>
    </div>
</div> <!-- # C O N T A I N E R -->


    <script>
    $(function(){

    var $container = $('#container');

    $container.isotope({
        itemSelector : '.element',
        filter: '*:not(.before)'
    });

    // custom layout mode spineAlign
    $.Isotope.prototype._spineAlignReset = function() {
        this.spineAlign = {
            colA: 0,
            colB: 1
        };
    };

    $.Isotope.prototype._spineAlignLayout = function( $elems ) {
        var instance = this,
        props = this.spineAlign,
        gutterWidth = Math.round( this.options.spineAlign && this.options.spineAlign.gutterWidth ) || 0,
        centerX = Math.round(this.element.width() / 2);

        $elems.each(function(){
            var $this = $(this),
            isColA = props.colB > props.colA,
            x = isColA ?
            centerX - ( $this.outerWidth(true) + gutterWidth / 2 ) : // left side
            centerX + gutterWidth / 2, // right side
            y = isColA ? props.colA : props.colB;
            instance._pushPosition( $this, x, y );
            props[( isColA ? 'colA' : 'colB' )] += $this.outerHeight(true);
        });
    };

    $.Isotope.prototype._spineAlignGetContainerSize = function() {
        var size = {};
        size.height = this.spineAlign[( this.spineAlign.colB > this.spineAlign.colA ? 'colB' : 'colA' )];
        return size;
    };

    $.Isotope.prototype._spineAlignResizeChanged = function() {
        return true;
    };  

    $(function(){

        var $container = $('#container');

        $container.isotope({
            itemSelector : '.element',
            layoutMode: 'spineAlign',
            spineAlign: {
                gutterWidth: 20
            }
        });


        var $optionSets = $('#options .option-set'),
        $optionLinks = $optionSets.find('a');

        $optionLinks.click(function(){
            var $this = $(this);
            // don't proceed if already selected
            if ( $this.hasClass('selected') ) {
                return false;
            }
            var $optionSet = $this.parents('.option-set');
            $optionSet.find('.selected').removeClass('selected');
            $this.addClass('selected');

            // make option object dynamically, i.e. { filter: '.my-filter-class' }
            var options = {},
            key = $optionSet.attr('data-option-key'),
            value = $this.attr('data-option-value');
            // parse 'false' as false boolean
            value = value === 'false' ? false : value;
            options[ key ] = value;
            if ( key === 'layoutMode' && typeof changeLayoutMode === 'function' ) {
            // changes in layout modes need extra logic
                changeLayoutMode( $this, options )
            } 
            else {
                // otherwise, apply new options
                $container.isotope( options );
            }

            return false;
        });

    });

    // filter buttons for shadowbox
    $('#filters a').click(function(){
        var selector = $(this).attr('data-option-value');
        $container.isotope({ filter: selector });

        // don't proceed if no Shadowbox yet
        if ( !Shadowbox ) {
            return false;
        }

        Shadowbox.clearCache();

        $container.data('isotope').$filteredAtoms.each(function(){
            Shadowbox.addCache( $(this).find('a[rel^="shadowbox"]')[0] );
        });

        return false;
    }); 


});
    </script>

appreciate any nudges in the right direction

thanks

edit:
i’ve also been trying another approach, of using jquery to resize the container when the links are clicked. but this has its own problems. i can get it to resize, but when the filter changes it won’t keep the images inside the container, instead they are left outside the newly formed small container until you click again and then they reposition themselves inside to fit. so close!

the code i was trying for this:

    // change the width of the container depending on the filter
    if ( $this.hasClass('thin') ) {
        $container
        .css({'width': '636px','margin-left': '132px'})
        .isotope('reLayout');
    }
    if ( $this.hasClass('thick') ) {
        $container
        .css({'width': '960px','margin-left': '0'})
        .isotope('reLayout');
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:08:35+00:00Added an answer on May 31, 2026 at 1:08 pm

    got it working after a looooong time.

    for anyone who is interested I used JSON to allow two different values in each link, so my options ended up looking like this:

    <section id="options">    
        <ul id="filters" class="option-set clearfix" data-option-key='["filter", "layoutMode"]'>
            <li><a href="#filter" data-option-value='["*:not(.before)", "fitRows"]' class="selected">everything</a></li>
            <li><a href="#filter" data-option-value='[".modern", "fitRows"]'>modern</a></li>
            <li><a href="#filter" data-option-value='[".traditional", "fitRows"]'>traditional</a></li>
            <li><a href="#filter" data-option-value='[".commercial", "fitRows"]'>commercial</a></li>
            <li><a href="#filter" data-option-value='[".automotive", "fitRows"]'>automotive</a></li>
            <li><a href="#filter" data-option-value='[".bespoke", "fitRows"]'>bespoke</a></li>
            <li><a href="#filter" data-option-value='[".before, .after", "spineAlign"]'>before <span style="font-size:10px;">&</span> after</a></li>
        </ul>
    </section> <!-- # O P T I O N S -->
    

    i then called both values one after the other in the script like:

    // data strings which JSON will call to get attribute
    dataValue = $this.attr('data-option-value');
    dataKey = $optionSet.attr('data-option-key');
    
    // C H A N G E   T H E   F I L T E R   O N   C L I C K
    var filterOptions = {},
        key = ($.parseJSON(dataKey)[0]),
        value = ($.parseJSON(dataValue)[0]);
    
    // parse 'false' as false boolean
    value = value === 'false' ? false : value;
    filterOptions[ key ] = value;
    if ( key === 'layoutMode' && typeof changeLayoutMode === 'function' ) {
      // changes in layout modes need extra logic
      changeLayoutMode( $this, filterOptions )
    } 
    else {
      // otherwise, apply new options
      $container.isotope( filterOptions )
    }
    
    
    // C H A N G E   T H E   L A Y O U T   O N   C L I C K                  
    var layoutOptions = {},
        key = ($.parseJSON(dataKey)[1]),
        value = ($.parseJSON(dataValue)[1]);
    
    // parse 'false' as false boolean
    value = value === 'false' ? false : value;
    layoutOptions[ key ] = value;
    if ( key === 'layoutMode' && typeof changeLayoutMode === 'function' ) {
      // changes in layout modes need extra logic
      changeLayoutMode( $this, layoutOptions )
    } 
    else {
      // otherwise, apply new options
      $container.isotope( layoutOptions )
    }
    

    i’m still new with jquery so it might not be the best way, but it worked, WAHOO!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I am trying to loop through a bunch of documents I have to put
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.