Page refresh with URL params
See original GitHub issueI have all urls using navigo routing. All of them are working on page refresh except the one with URL parameter (/course/:id
). On page refresh /course/:id
is loading home page!
Navigation without page refresh is working fine.
Given below are the relevant code from server and client.
What am I missing?
Server (NodeJS+Express)
redirects to /index.html
...
app.use('/courses', express.static('public'));
app.use('/course/:courseId', express.static('public'));
...
Client
router.on({
'*': function () {
console.log("*");
$('#header').show();
$('#footer').show();
$(home).find('#twitter').html('');
$(home).find('#twitter').html(require("../html/twitter.html"));
$('#main').html(home);
},
'/courses': function () {
console.log("/courses");
$('#header').show();
$('#footer').show();
$('#main').html(courses);
$('#courseslist').show();
var courseObj = require('./course')();
courseObj.showCourses();
},
'/course/:id': function (params, query) { // REVISIT Page reload breaks
console.log("/course/"+params.id);
$('#header').show();
$('#footer').show();
$('#main').html(course);
var courseObj = require('./course')();
courseObj.showCourse(parseInt(params.id));
},
...
Thanks in advance!
Issue Analytics
- State:
- Created 6 years ago
- Comments:8
Top Results From Across the Web
Append to URL and refresh page - javascript - Stack Overflow
I am looking to write a piece of javascript that will append a parameter to the current URL and then refresh the page...
Read more >How to reload the current page with a query string parameter
I'm trying to refresh a page when ...
Read more >How to Reload a Page using JavaScript - W3docs
JavaScript provides a trendy among developers — location.reload() , which finds ways to reload the page at the current URL. The window.location object...
Read more >Location Reload Method: How to Reload a Page in JavaScript
JavaScript Location.reload() method provides means to reload the page at current URL. The syntax is the following:.
Read more >Change url parameters without refreshing the page with ...
For tracking purpose, we sometimes want to update the page url parameters but not refresh that page (ie: single page application).
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@dancespiele Yup that did it! Thanks a tonne, you are a life saver.
I ended up only with the following change:
… in stead of…
Note : It also worked without…
Been stuck with is problem for weeks, can’t thank you enough @dancespiele
@c-bik try with this:
In your case, maybe because you are using express you need to specify the root url. Another thing is that you don’t need data-navigo, it is only to create path that is not previously included in the router.