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

Viewing 10 posts - 1 through 10 (of 19 total)
  • Anonymous
    #72796

    I’d like to update filter element through javascript.
    this changes(reset) a dropdown filter element itself but another elements does not reacts.
    jQuery(‘.sf-field-taxonomy-some_category select’).val(”);

    How do i make another elements reacts?

    Trevor
    #72828

    You mean that it is not triggering the Auto Count refresh mechanism? This is because that jQuery val() method does not tell the browser that anything has changed and so the code listener that is used by the plugin thinks that nothing has changed. I asked Ross on a different project (of my own) if that could be done and I do not think we resolved it.

    Anonymous
    #72981

    Yes, I think it’s Auto Count. Not auto submit or reload page.
    I have two dropdowns for different criteria and I don’t want to let user select both.

    Anonymous
    #73000

    Actually execute this after changed dropdown worked.
    jQuery(‘.sf-field-taxonomy-some_category select’).trigger(‘change’);

    My server was very slow yesterday so I didn’t notice that this is working.

    Trevor
    #73082

    So, this is resolved now?

    Anonymous
    #73386

    One more question,
    If I set dropdown value from another filter element’s event,
    url query string remains and result is different from what I expected.

    jQuery(‘.sf-field-taxonomy-taxonomy1 select’).on(‘change’,function(){
    jQuery(‘.sf-field-taxonomy-taxonomy2 select’).val(”);
    });

    url query strings after update
    /search/?_sft_taxonomy1=xxx&_sfm_taxonomy2=yyy
    _sfm_taxonomy2 should be removed.

    Anonymous
    #73397

    Or should I just use redirection?

    var newurl = location.search.replace(/_sfm_something=[^&]+/,”);
    location.href = location.pathname+newurl;

    Trevor
    #73413

    I am not sure what would change the URL.

    Anonymous
    #73417

    As I wrote above, changing filter element via javascript event of another filter does not work properly so I thought rewriting url would be simpler.
    I confirmed rewriting url(redirect) works fine.

    Anonymous
    #73419

    At first, two filters selected so there are two query strings
    /search/?_sft_taxonomy1=xxx&_sfm_taxonomy2=yyy

    I should be like this when change fitler1 and filter2 is reset.
    /search/?_sft_taxonomy1=zzz

    But filter2’s query remains
    /search/?_sft_taxonomy1=zzz&_sfm_taxonomy2=yyy

Viewing 10 posts - 1 through 10 (of 19 total)