So I have a page select in my theme's customizer and a bit of code to make the preview change when the user selects a different page:
api('gm_pages', function (setting) {
var pageID = setting.get();
setting.bind( function onChange( pageID ) {
api.previewer.previewUrl.set(api.settings.url.home + '?page_id=' + pageID);
})
});
I use this simple plugin so user can reset customizer settings to default:
https://plugins.trac.wordpress.org/browser/customizer-reset-by-wpzoom/trunk
When you click a button, you get a warning popup then if you click through it, the plugin deletes the theme_mod data and refreshes the entire site.
The problem I am having is when I do this, the page dropdown option returns to the default "home" page but the preview URL doesn't update and stays on the last page the user had selected. If I console.log(pageID); the correct page number (showing in the select box) shows, it's the preview that doesn't run for some reason.
Edit: I triedcan add this because the reset refreshes the whole pageline in:
if (performance.navigation.type === 1) {
api.previewer.previewUrl.set(api.settings.url.home )+ '?page_id=' + pageID);
}
and it worksthat does the trick, but how can I can't do that as every time the page refreshes the user would return tothis conditionally without needing 2 lines of the home page.
Can someone point out what could be happening heresame code?