I have a site on Drupal 8 and I update a block view with the following code :
(function ($, Drupal) {
'use strict';
setInterval(function() {
$('.region-navigation-logo .view-display-id-block_3').trigger('RefreshView');
}, 10000);
})(jQuery, Drupal);
This code updates the logo of the site. The problem is that if I scroll the page down, it goes up a little automatically every 10 seconds.
You can test on my site with :
https://www.s1biose.com/fr/user/login
identifier : demo
password : demo
Then click on the logo of the site, scroll down the home page and wait 10 seconds. You will see the page go up some pixels every 10 seconds.
UPDATE
The following code works, but it is applied to all views of the site.
I want to apply it only to 2 views :
message_activity_stream_timeline_public
and
message_activity_stream_timeline_private
How to do this ?
function message_activity_stream_ajax_render_alter(array &$data) {
$view_name = '<view_name>';
$view_dom_id = '<view_dom_id>';
$selector = '.js-view-dom-id-' . $view_dom_id;
foreach ($data as $key => $value) {
if ($value['command'] === 'viewsScrollTop' && $value['selector'] === $selector) {
unset ($data[$key]);
break;
}
}
}
How to use this code with 2 views ?