This is a migrated thread and some comments may be shown as answers.

Router Not Updating URL

1 Answer 46 Views
SPA
This is a migrated thread and some comments may be shown as answers.
Ashleigh L
Top achievements
Rank 1
Ashleigh L asked on 08 Oct 2015, 07:44 PM

I've got my router and routes set up, and now I'm trying to implement the navigation, but router.navigate isn't updating the URL and I'm not sure why.

There's a link on my page that's meant to pull up a different view; the onclick for the link is bound to the navigatePage function:

function navigatePage(page) {  
    var category_id = page.data("categoryid");
    var page_id = page.data("pageid"); 
     
    router.navigate("/category/" + category_id + "/page/" + page_id);
}

This is the route it's going to:

router.route("/category/:categoryid/page/:pageid", function(categoryid, pageid) {          
    openPage(categoryid, pageid);
});

Which then calls the function to actually change the views. However, when I run the page, I can see (via console.log) that navigatePage is being called, then the route, but the URL never changes and the default route kicks in (I'm assuming because the URL hasn't been modified?).

So I went to record what I was seeing for you, and noticed that the URL is actually changing (you can see it blip in the vid), but the somehow it's being reset. I don't have any other navigate calls in my javascript. Here's the default route, in case that's relevant:

router.route("/", function() { 
    generateView();
});

Where am I going wrong?

1 Answer, 1 is accepted

Sort by
0
Plamen Lazarov
Telerik team
answered on 12 Oct 2015, 11:21 AM

Hello shimmoril,

I am afraid the provided information is not sufficient to determine what exactly goes wrong. In order to better assist you, we will need a runnable demo which demonstrates your exact setup. This will allow us to investigate the issue locally and determine the root cause for the observed behavior. 

Thank you for your cooperation. 

Regards,
Plamen Lazarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
SPA
Asked by
Ashleigh L
Top achievements
Rank 1
Answers by
Plamen Lazarov
Telerik team
Share this question
or