5

I have an exposed filter for one of my views and I added a drop-down select for the users to pick from.

In Views for Drupal 7 there was an Auto-Submit check box, but I can not seem to find it in Drupal 8 at all. Does anyone know where it may be hiding or how I can get the filter to auto-submit.

5

While tracking the above issue is good for long-term success... if you need this functionality ASAP, here's a tiny bit of a hack to get it working with some custom javascript. Inside your theme's JS, add something like the following:

// Autosubmit 'view-class-here' views exposed form.
$("div.view-class-here").find("form.views-exposed-form").find("select").bind("change", function () {
  $(this).closest("form").trigger("submit");
}).end().find("input[type='submit']").addClass("visually-hidden");

This will do the following:

  1. Look at any select item in a given views exposed form (for a view with a class .view-class-here), and trigger a submit whenever the select list is changed.
  2. Hide the 'Submit'/'Apply' button associated with the exposed form.

If you want to trigger the submit on input fields, change the .bind() to use something like input:checkbox or input for any kind of input (though that might need more tweaking to make sure things don't go crazy!).

2

This functionality is currently in flux, and may eventually be moved to CTools, Core, or a small module. Track issue https://www.drupal.org/node/2475595 for updates.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.