How to create redirect url in canjs


#1

Previously we are using canv2 whereas we have recently updated our application to canv3 so i am looking a way to redirect a user to another page after he click a button.

For example in canv2 in our click function we used:
route.data.assign({
‘section’:‘merchandizing’,
‘page’:‘customers’,
‘action’: ‘edit’,
‘id’:id
});

but I am looking a way in v3, I have check can-route-pushstate it is open a page but the issue is its maintaining history and also URL in the browser does not change even it redirect to a new page
I have tried following examples but that didn’t work

route.replaceStateOnce(‘section’, ‘page’,‘action’);
route.attr( { section: “xxxxxxx”, page: ‘xxxxx’,action:‘create’ });

route.data.set({section: ‘merchandizing’,page:‘customers’,action:‘create’});

I am looking for similar way - history.pushState(’’,’’, ‘/’ + ‘xxxxxx’ + ‘/’ + ‘xxxxxxx’ + ‘/’ + ‘create’);


#2

Does route.data.assign not work for you in 3.0? It should.


#3

Hi its works where as the url in browser does not change. The page change to what is define in assign object but i also want the url should change.

		route.data.assign({
			'section':'abcd',
			'page':'efth', 
			'action': 'create',
		});	

it takes user to create page in abcd/efgh/create where as the url does not change and also when i click any of the url in navigation then create page of that url automatically open. I think it maintaining history or storing action in cache thats why action automatically append in all other urls.


#4

Just an update for anyone else who runs into this issue: in DoneJS apps, done-autorender automatically calls route.start() for you, so you don’t need to do that (or set up your own route.data) in your app.