I am trying to programatically navigate to a new route based on things happening in my javascript, but sometimes the page thinks it’s still on the current page and tries to load things that do not belong, resulting in javascript errors.
How can I update currentInstruction
or make navigateToRoute
function like I expect? Or am I missing some key component that would prevent this from happening?
Here’s my javascript code where I’m navigating to a new route:
search.js:
this.router.navigateToRoute('customer', params);
console.log('current navigation', this.router.currentInstruction.config.name);
// when I log this, sometimes it shows 'customer' and sometimes 'search'
app.js
configureRouter( config, router )
{
config.title = 'ARIS';
config.options.pushState = true;
config.options.root = '/';
config.map([
{
route: '',
name: 'home',
moduleId: PLATFORM.moduleName('home'),
nav: true,
title: 'Home',
},
{
route: 'aris',
name: 'aris',
moduleId: PLATFORM.moduleName('aris'),
nav: false,
title: 'ARIS',
},
{
route: 'login',
name: 'login',
moduleId: PLATFORM.moduleName('login'),
nav: false
},
{
route: 'customer/:debtor_id?/:inv_num?',
name: 'customer',
moduleId: PLATFORM.moduleName('customer'),
nav: true,
href: 'customer',
title: 'Customer',
//activationStrategy: activationStrategy.invokeLifecycle,
},
{
name: 'search',
route: 'search',
moduleId: PLATFORM.moduleName('search'),
nav: true,
title: 'Search/Worklist',
settings: {dropdown: true}
},
]);
config.mapUnknownRoutes('home');
config.fallbackRoute('home');
this.router = router;
}
I tried using activationStrategy
, but this didn’t change what was going on, so I commented it out.
Any insight would be appreciated.