You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today I ran into the need (yet again) to refresh a View after a custom form is submitted, (i.e. the view was already on the page and the form is building custom exposed filters to be appended to the path of the View that I want to refresh).
Here's a handy function that removes the View from DrupalGap, so it can be reloaded/refreshed/re-rendered (place this in a custom DG7 module):
functiondgRemoveView(viewId){// Remove the existing view from the DOM.$('#'+viewId).remove();// Remove the view from DrupalGap's internal tracker.varviews=drupalgap.views;varindex=views.ids.indexOf(viewId);if(index!=-1){views.ids.splice(index,1);}// Remove the pageshow event so it can fire again.varevents=drupalgap.page.jqm_events;index=events.indexOf("pageshow-_theme_view-"+viewId);if(index!=-1){events.splice(index,1);}}
Then for example, you can remove the view then re-append it to the content region:
// Remove the view from the DOM.
dgRemoveView('my-view-id');
// Get the new html ready.
var content = {};
content.my_view = { /*... A Views Render Array using the same id "my-view-id" ... */ };
var html = drupalgap_render(content);
// Append the html to the content region.
var selector = '#' + drupalgap_get_page_id() + ' .region_content';
$(selector).append(html).trigger('create');
A little hacky, but it gets the job done! I'll plan to move dgRemoveView() into DG7 core eventually, give it a new name, and an appropriate home in the docs.
The text was updated successfully, but these errors were encountered:
Today I ran into the need (yet again) to refresh a View after a custom form is submitted, (i.e. the view was already on the page and the form is building custom exposed filters to be appended to the path of the View that I want to refresh).
Here's a handy function that removes the View from DrupalGap, so it can be reloaded/refreshed/re-rendered (place this in a custom DG7 module):
Then for example, you can remove the view then re-append it to the content region:
A little hacky, but it gets the job done! I'll plan to move
dgRemoveView()
into DG7 core eventually, give it a new name, and an appropriate home in the docs.The text was updated successfully, but these errors were encountered: