Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Jon Schroeder

    (@jonschr)

    Please note that I am using the select2 library; if I were just using the standard controls, this would be a simple jQuery script to detect the state of the select box, then hide/show things accordingly, but it looks a step or two more complex when using that library.

    Plugin Author Jonathandejong

    (@jonathandejong)

    Hi Jon,

    I started out thinking trades was a term not a tax so had to rewrite this now.. hah.

    So here’s how I’d do it as simple as possible. You could spruce it up a bit by using CSS classes and css3 animations/transitions for showing hiding instead if you’d like

    * Hide trades with css #beautiful-taxonomy-filters-tax-job-name{ display:none; }
    * Check for the value being set in the job categories and if it’s blue collar just show the whole thing.

    jQuery('#select-job-industry')on("change", function (e) {
    var val = jQuery(this).val();
    if(val === 'artisans'){ //show bluecollar, hide whitecollar
    jQuery('#beautiful-taxonomy-filters-tax-job-name').slideDown();
    jQuery('#beautiful-taxonomy-filters-tax-job-categories').slideUp();
    }else{ //and vise versa
    jQuery('#beautiful-taxonomy-filters-tax-job-name').slideUp();
    jQuery('#beautiful-taxonomy-filters-tax-job-categories').slideDown();
    }
    });

    Thread Starter Jon Schroeder

    (@jonschr)

    Wow, this is a much more specific answer than I was expecting. I’ll play around with that and see if I can get that to work.

    Much appreciated, and great work – this is massively better than every other filter system for taxonomies I could find. My only feature request would be the ability to do multi-select, but that’s probably not a simple feature to add.

    Plugin Author Jonathandejong

    (@jonathandejong)

    Do so 🙂 I think it should work but I haven’t checked it for spelling errors etc.

    Thank you! I couldn’t find anything good either, hence this plugin spawned 😉 Please leave a review if you like. It really helps me out.

    Thread Starter Jon Schroeder

    (@jonschr)

    That’s OK, I needed some help getting started is all.

    Here’s the code ultimately used, since it might come in handy for someone else someday:
    https://gist.github.com/redblueconcepts/6bc52166db037e880772

    This corrects for a few issues I found in actually implementing it:
    * A user could make a selection on a conditional field, then hide it. This resets both the field and the select when the field which is the source of the conditional is changed to avoid accidental criteria being added to the search
    * Conditional fields are hidden by default, then only shown when the selection is made

    Plugin Author Jonathandejong

    (@jonathandejong)

    Cool! Much better than my hasty directly-in-commentfield hacking 🙂

    I’ll mark this topic as solved then!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Conditional logic’ is closed to new replies.