在Drupal视图中启用自动提交

Enable autosubmit ONLY for sort exposed filter in Drupal Views

本文关键字:提交 启用 Drupal 视图      更新时间:2023-09-26

我有一个暴露的过滤器块,其中包含多个选择过滤器,包括"sort by"类型的过滤器。所有的过滤值都是通过按"Apply"按钮提交的。

我想给自动提交功能只有"排序"过滤器。我已经找到了下面的代码,但它不工作,即使它应该。是否有可能只针对一个过滤器?

代码:

$('.views-exposed-form select').change(function() { $(this).parents('form').submit(); });

任何提示将非常感激!

// Wait until document fully loaded
jQuery(document).ready(function($) {
    // Check if the filter exists
    if($('.views-exposed-form select').length){
        // Your change function
        $('.views-exposed-form select').change(function() {
            // Submit the form
            $(this).parents('form').submit();
        });
    }
});