{"id":691,"date":"2014-02-18T21:55:39","date_gmt":"2014-02-18T21:55:39","guid":{"rendered":"http:\/\/www.advancedwebhelp.com\/blog\/?p=691"},"modified":"2014-02-18T22:18:41","modified_gmt":"2014-02-18T22:18:41","slug":"drupal-7-filter-on-change","status":"publish","type":"post","link":"https:\/\/www.advancedwebhelp.com\/blog\/2014\/drupal-7-filter-on-change","title":{"rendered":"Drupal 7 filter on change"},"content":{"rendered":"<p>There are several location that I offer to filter lists in Drupal 7.   These locations tend to require that you select an option from a dropdown list, then, click a button that says &#8220;Filter&#8221;, &#8220;Apply&#8221; or other text.   This is not a problem, but, some interfaces should just execute when the filter is selected, without clicking an apply button.<\/p>\n<p>As an example, you may create a view that exposes a filter to the page a viewer will see.   The visitor may want to select a filter and have the filter applied without having to do a second step of &#8220;applying&#8221; the filter.   This may be accomplished by a quick chunk of jQuery.   This chunk may be added as a module, drupal_add_js or simply added to an invisible block on the page.<\/p>\n<p>For demonstration purposes, assume that you have a select filter with the id=edit-field-business-category-tid.   To activate this filter on change of the selection use:<\/p>\n<p><code><\/p>\n<pre>\r\n\r\n jQuery(\"#edit-field-business-category-tid\").change(function() {\r\n     jQuery(this).parents(\"form\").submit() ;\r\n }) ;\r\n\r\n<\/pre>\n<p><\/code><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are several location that I offer to filter lists in Drupal 7. These locations tend to require that you select an option from a dropdown list, then, click a button that says &#8220;Filter&#8221;, &#8220;Apply&#8221; or other text. This is not a problem, but, some interfaces should just execute when the filter is selected, without [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-691","post","type-post","status-publish","format-standard","hentry","category-drupal"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/posts\/691","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/comments?post=691"}],"version-history":[{"count":2,"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/posts\/691\/revisions"}],"predecessor-version":[{"id":693,"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/posts\/691\/revisions\/693"}],"wp:attachment":[{"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/media?parent=691"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/categories?post=691"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/tags?post=691"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}