when a user submit the view's exposed form the site is reloaded and the page's focus is not on the view's results but on the very top of the page. I use quite a few exposed filters above a table view. Locating the filters somewhere else is not possible (e.g. sidebar).
I am trying to solve this using JS. My attempts:
(function ($) {
'use strict';
$(document).ready(function() {
if( $('.views-table').length ){
$("html, body").animate({ scrollTop: $(".views-table").offset().top }, "slow");
}
});
}(jQuery));
This works when I apply a filter but it also works when I used load the view page without filters applied. Unfortunately, I don't have any style classes that are only applied to the filtered view table.
(function ($) {
Drupal.behaviors.form_submit_processor = {
attach: function (context, settings) {
$("form#views-exposed-form-standortanalyse-page-1").submit(function(e) {
$("html, body").animate({ scrollTop: $(".views-table").offset().top }, "slow");
});
}
}
}(jQuery));
When using this approach the scrolling works when hitting the submit button but after page reload the scroll setting is lost again.
Does someone has any idea how this can be achieved?