Child Routing - Function - SOS for Rob

20 views
Skip to first unread message

Garry Taylor

unread,
Jun 21, 2015, 8:45:14 AM6/21/15
to duran...@googlegroups.com
SOS to Rob!!!

When using child routing I would like it if the child called activate only if the parent router URL is different/changed.

For example: When going to any page in sample 1 the child router will call activate. The data will be cached. This happens even if you use a function return and not an object literal.
The issue is that moving to sample 2 the reviews/spec will be cached on the view and therefore show the wrong data. Sample 1 reviews will show in sample 2 url.

The possible solution is to set everything up in Activate method however this means that every-time we go to this child page the code will pull the data from the database again as activate appears to be called every single time the child router is shown.

Sample 1
  1. http://localhost/product/369 parent route
  2. http://localhost/product/369/reviews child route
  3. http://localhost/product/369/specifications child route
Sample 2
  1. http://localhost/product/368 parent route
  2. http://localhost/product/368/reviews child route
  3. http://localhost/product/368/specifications child route
Sample 3
  1. http://localhost/application/368 parent route
  2. http://localhost/application/368/addressdetails child route
  3. http://localhost/application/368/addressdetails/addressdetails/12 child route
  4. http://localhost/application/368/contactdetails child route
  5. http://localhost/application/368/contactdetails/contactdetail/405 child route
The issues get even more complicated when all my child routers are modules that allow us to update an application/client. If the user moves from Sample 3.2 to Sample 3.4 and back again all the details/changes will be lost as the activate will be called, pull the data from the database and whip out and changes on the module.

We want the child router to not call activate if we have not moved to a new parent router. For example from application 368 to 369
We want the child router to cache the data whilst on the same parent route
We want the child router to create a new instance when the parent router has changed

Ta for any help in advance.. I know this is a little complicated. My next step if to make my own router and I don't fancy that job!
Reply all
Reply to author
Forward
0 new messages