The code that creates the DOM ID for each view on a page is in the 'template_preprocess_views_view' by way of a static variable counter. This method will not work as 'dom-id-1' would get assigned to an un-cached view, but 'dom-id-1' may have already been assigned to a view that has been previously cached since 'template_preprocess_views_view' is not called again for cached views.
This has been an issue on one of our live sites where there are views on the page with different caching settings.
I have a work around that sets the DOM ID in an 'hook_views_pre_view' implementation:
function sample_views_pre_view(&$view, &$display_id, &$args) {
static $dom_id = 1;
$view->dom_id = !empty($view->dom_id) ? $view->dom_id : $dom_id++;
}
Having the DOM ID generation in a 'hook_views_pre_view' implementation would work better as this function get executed before any cache hit would take place for a view. So, I suggest moving it from 'template_preprocess_views_view'.
Comments
Comment #1
dawehnerThis is a duplicate of #655002: 2 separate ajax views on a page => results updated in both places.