Global handlers of view events

Learn about handling view lifecycle events globally

Hi-Framework Views come with 3 lifecycle events: preLoad, postLoad and close. As views run inside templates, we developed them in a way they notify the template holding them whenever their lifecycle events occur.

Handler functions

Lets now see how to declare and use the view global events handlers

onPreLoad handler

Every time a preLoad happens in a view, this handler on your template controller is fired.

$onPreLoad : function(route,scope,html){
        
  //Do whatever
		
}

If you wish to change the view's markup dynamically, you just have to return the changed markup version in the method.

$onPreLoad : function(route,scope,html){
        
    //Do whatever
    return newMarkup;
	
}

onPostLoad handler

This handler is fired every time a view's postLoad happens.

$onPostLoad : function(route,viewScope){
		
    //Do whatever

}

onClose handler

This handler is fired every time just after a view is closed.

$onClose : function(route){
	    
   //The view is already closed
    
}

NOTICE
All view events get executed before the ones in the template

Handler arguments

Find below the description for each of the arguments passed to the handler functions:

Represents the MVC route object. Represents the view's $scope object. Represents the View's markup string
Github Repository