I have some views that I want to refresh in a time interval (15sec) OR if there is changes in the content. For that I tried to use module "Views Auto Refresh". It works fine for a time interval but only if I have one view in a page.
If I have multiple views inside a panel (using Panels module), only one of the views is refreshed.
Is there any other way (module or custom code) to achieve this behaviour?
Thanks!
EDIT: As suggested, I tracked the ajax requests. In my case I'm refreshing every 15seconds. In a panel with 2 views I notice that I have only one request every 15sec, should I have two?!?!? Anyway, below is the piece of code I get when clicking in the function in red in the picture (I think is this one). The debug highlights the following line:
$(anchor).trigger('click');
Drupal.views_autorefresh.timer = function(view_name, anchor, target) {
Drupal.settings.views_autorefresh[view_name].timer = setTimeout(function() {
clearTimeout(Drupal.settings.views_autorefresh[view_name].timer);
// Turn off "new" items class.
$('.views-autorefresh-new', target).removeClass('views-autorefresh-new');
// Handle ping path.
var ping_base_path;
if (Drupal.settings.views_autorefresh[view_name].ping) {
ping_base_path = Drupal.settings.views_autorefresh[view_name].ping.ping_base_path;
}
// Handle secondary view for incremental refresh.
// http://stackoverflow.com/questions/122102/what-is-the-most-efficient-way-to-clone-a-javascript-object
var viewData = Drupal.settings.views_autorefresh[view_name].ajax.submit;
var viewArgs = Drupal.settings.views_autorefresh[view_name].view_args;
if (Drupal.settings.views_autorefresh[view_name].incremental) {
if (!viewData.original_view_data) viewData.original_view_data = $.extend(true, {}, viewData);
viewData.view_args = viewArgs + (viewArgs.length ? '/' : '') + Drupal.settings.views_autorefresh[view_name].timestamp;
viewData.view_base_path = Drupal.settings.views_autorefresh[view_name].incremental.view_base_path;
viewData.view_display_id = Drupal.settings.views_autorefresh[view_name].incremental.view_display_id;
viewData.view_name = Drupal.settings.views_autorefresh[view_name].incremental.view_name;
}
viewData.autorefreshRequest = 'autorefreshRequest';
Drupal.settings.views_autorefresh[view_name].ajax.submit = viewData;
// If there's a ping URL, hit it first.
if (ping_base_path) {
var pingData = { 'timestamp': Drupal.settings.views_autorefresh[view_name].timestamp };
$.extend(pingData, Drupal.settings.views_autorefresh[view_name].ping.ping_args);
$.ajax({
url: Drupal.settings.basePath + ping_base_path,
data: pingData,
success: function(response) {
if (response.pong && parseInt(response.pong) > 0) {
$(target).trigger('autorefresh_ping', parseInt(response.pong));
$(anchor).trigger('click');
}
else {
Drupal.views_autorefresh.timer(view_name, anchor, target);
}
},
error: function(xhr) {},
dataType: 'json',
});
}
else {
$(anchor).trigger('click');
}
}, Drupal.settings.views_autorefresh[view_name].interval);
}