views.js 969 B

1234567891011121314151617181920212223242526272829
  1. /**
  2. * @file
  3. * Make Hierarchical Select work in Views' exposed filters form.
  4. *
  5. * Views' exposed filters form is a GET form, but since Hierarchical Select
  6. * really is a combination of various form items, this will result in a very
  7. * ugly and unnecessarily long GET URL, which also breaks the exposed filters.
  8. * This piece of JavaScript is a necessity to make it work again, but it will
  9. * of course only work when JavaScript is enabled!
  10. */
  11. if (Drupal.jsEnabled) {
  12. $(document).ready(function(){
  13. $('.view-filters form').submit(function() {
  14. // Remove the Hierarchical Select form build id and the form id, to
  15. // prevent them from ending up in the GET URL.
  16. $('#edit-hs-form-build-id').remove();
  17. // Prepare the hierarchical select form elements that are used as
  18. // exposed filters for a GET submit.
  19. $('.view-filters form')
  20. .find('.hierarchical-select-wrapper')
  21. .trigger('prepare-GET-submit');
  22. });
  23. });
  24. }