I have an app I’m writing in which the main page may link to a detail page with parameters that then Ajax in the contents of that page (basically in the route scenario below, detail.html is just a template page and the data is live).
routes: [
{
path: '/',
url: './index.html',
pageName: 'index',
},
{
path: '/detail/:id',
url: './detail.html',
pageName: 'detail',
}
This works fine if it’s just index > detail, but when I have another detail page that uses the same template as detail.html, navigating to that index > detail:1 > detail:2 doesn’t load the data into the new detail:2 page, but on detail:1 (I know this because when I navigate back to detail:1 it has the :2 data on it briefly before Ajax updates it).
I suspect it may be either because the DOM manipulation I’m doing to add the data sees detail:1 still in the DOM. Or it may be how I’m triggering getting the data
$(document).on('page:init', '.page[data-name="detail"]', function (page) {
detailInit();
});
I have console.logged the parameter ID, and it picks up on that correctly, but $(’#element’).html(‘new data’); to change the template is putting that in the wrong place.
Is it even possible to load the same page with different parameters from itself? Maybe there’s a way I can tell my script to target the page its just loaded rather than the first one in the DOM?