Refresh widgets in a layout on page navigation?

1
Hello,   I have a widget contained in a layout that all of my pages use. The widget's content depends on the current page content, so when the user navigates to a new page I would like the widget to either run a function to update its content or re-initialize. Currently when I switch pages, the widget does not refresh or call the update function. It does seem to call the resize function though.   Is there an easy way to run a function or re-initialize a widget inside of a layout when the user changes the page?   Thanks, Matt
asked
3 answers
4

Take a look at the onNavigation event documented here. This event is fired after each page navigation, so your widget could be configured to listen for that event and respond accordingly.

answered
2

We encountered the same challenge and used "onNavigation" event (as Eric mentions), and it works.

this.connect(this.mxform, 
"onNavigation", 
	function(){
		var formObject=this.mxform.getContext()&&this.mxform.getContext().getTrackObject();

....

	}
);

 

answered
1

Hello Matt,

I don't think there is an easy way to force a widget's update function outside of triggering it via updating the containing entity.

 

If this is not your widget I would suggest adding the widget on the page which would mean it gets rebuilt when you load a new page. 

If this is your widget you can add event listeners for your functions, you could even look for DOM changes (using something like https://dom.spec.whatwg.org/#interface-mutationobserver) 

 

Hope this helps

answered