Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro update filter element through javascript?

Viewing 9 posts - 11 through 19 (of 19 total)
  • Trevor Moderator
    #73423

    I think I need to get input from Ross, the developer, yes?

    Ash
    #73426

    Ok, thank you.
    I tried same thing on other plugin before and just changing filter value via another filter’s event worked fine.
    So I didn’t think it’s so complicated.

    Ross Moderator
    #73431

    Hey Ash

    I’ve not tried to do what you are doing exactly but in theory it should work.

    So you want to clear one field if the other field is updated?

    I think what you are doing is fine, setting .val("").. when doing this, do you see the field itself change value? If so, then all you should need to do is submit the form (which will handle the building of the new URL) – $('.searchandfilter').submit(); – this will also work for an ajax powered search form.

    What you suggested above also sounds like it might do the trick (triggering a change event after you have set the val), you might need to trigger input or change and then you would need to do it here in your example:

    jQuery('.sf-field-taxonomy-taxonomy1 select').on('change',function(){
        jQuery('.sf-field-taxonomy-taxonomy2 select').val('').trigger('change');
        
    });

    Our next major version has quite a large rewrite and will include a JS api for doing this kind of thing much more easily.

    Hope that helps

    Ash
    #73443

    unfortunately none of those worked.
    query string of secondary filter remains and result come out empty because of it.

    Ash
    #73526

    So far only this method worked.

    jQuery(document).on("sf:ajaxstart", ".searchandfilter", function(){
      var tax1 = jQuery('.sf-field-taxonomy-tax1 select').val();
      if(location.search.search('_sft_tax1='+tax1) == -1){
        jQuery('.sf-field-taxonomy-tax2 select').val('');
      }
    });

    (edited by @trevorsf to add code tags to the code)

    Ross Moderator
    #73814

    Hey again Ash

    I will do some more tests next week on this and if there is a better way of doing this I will share with you. As mentioned though, this all needs a bit of a rework and I won’t be making any changes to this area of the plugin until the next major version where there will be an API to make all this super easy.

    Thanks

    Ash
    #73871

    Thank you.
    I think it’s ok to use sf:ajaxstart event for now since it’s working at least.
    Looking forward to next update!

    Trevor Moderator
    #73934

    Hi Ash, is this thread ready to be closed?

    Ash
    #74000

    Yes

Viewing 9 posts - 11 through 19 (of 19 total)

The topic ‘update filter element through javascript?’ is closed to new replies.