How to automatically submit Views Exposed Filters in Drupal
Categories
DrupalTutorial
Keywords
javascript

So you want to filter your Drupal Views automatically when users select a category in an exposed form?

It's really easy.

 

Simply add this Javascript Behavior to your custom theme. All your Views will be automatically filtered when on next clicks:


Drupal.behaviors.autoSubmitExposedFilters = {

  attach: function (context, settings) {

    $('.views-exposed-form .form-select').on('change', function() {

      $(this).parents('.views-exposed-form').find('.form-actions .form-submit').click();

    });

  }

}