I have two different blocks. One has a form and the other one is a view with some files uploaded from the form above.
On submit of the form I need to update the view results. I thought I could do it using js but I can't make it work.
Please check my code. Any advice would be helpful!
Drupal.behaviors.myViewsRefresh = {
attach: function( context , settings) {
var viewName = 'application_documents';
// Your views should be Ajax enabled
var instances = Drupal.views.instances;
var myViews;
// then simply need to iterate through the various
// views instances name to find the view
$.each( instances , function getInstance( index, element){
if(element.settings.view_name == viewName ){
myViews = '.view-dom-id-' + element.settings.view_dom_id;
}
});
$(document).once('mysubmitbutton').ajaxComplete(function(event, xhr, settings){
if(typeof myViews !== 'undefined'){
$(myViews).trigger('RefreshView');
}
});
}
}
I can get into the ajaxComplete but the view doesn't reload. The view id is correct.
Thank you in advance.