cancel
Showing results for 
Search instead for 
Did you mean: 

When using the router, page reload problem.

Former Member
0 Kudos
1,464

Now I'm using router with component.js and MyRouter.js file. However i have some problem.

First i click a page menu, it calls oninit() function correctly. but when i click a page menu at second times, onInit() function doesn't work.

How can i refresh page every time i click the page menu?

View Entire Topic
ugurkaya
Active Participant

Hey John,

You could use attachMatched / attachPatternMatched event for this purpose. It is triggered every time when page is displayed. For example on your detail page you can attach a function to be called everytime like this:

onInit : function() {

  this.getRouter().getRoute("detail").attachMatched(this.onRouteMatched, this);

},

onRouteMatched: function(oEvent){

// clear fields

}

former_member197071
Participant
0 Kudos

Hi Ugur,

Thanks but I m getting following error:

I am inside onRouteMatched()

Uncaught TypeError: I.fFunction.call is not a function


However it is successfully triggering method onRouteMatched() because it has returned the text which I wrote inside onRouteMatched() using console.log("I am inside onRouteMatched()").

ugurkaya
Active Participant
0 Kudos

Hey Ankur,

Is there any further information on the error log?


It is hard to tell what causes this error. You may want to check recent modifications on the application.

Regards

Ugur

former_member197071
Participant
0 Kudos

Hello Ugur,

It was my typo  mistake, I wrote

this.getRouter().getRoute("detail").attachMatched(this.onRouteMatched(), this);

instead of

this.onRouteMatched


Thanks for your help