I have a very simple bit of code that filters a dataset by retrieving the query parameter of the URL.
let queryValue = wixLocation.query;
$w( ‘#dataset1’ ).setFilter(wixData.filter().contains( ‘title’ , queryValue.category));
So, www.website.com/gallery?category= cats (for example) would filter the dataset on that page so that it only showed images from the cats category …
I put links in the menu so that the user can navigate to all of the filtered galleries as though they were separate pages. For some reason, this only works when I set the links to open the page in a new window, and not the same window.
Anyone know why?
Simply because your setFilter function is in onReady(run ONLY 1 time).
After you redirect the same page, the code won’t run again, so, please redirect the user using the code, then run the setFilter again.
I actually just fixed it right before I saw this …
I added a window.onChange function that ran the whole thing again with a new variable; it works perfectly now …
wixLocation.onChange( (location) => {
let queryValue2 = wixLocation.query;
$w( ‘#dataset1’ ).setFilter(wixData.filter().contains( ‘title’ , queryValue2.category));
} );
Is it possible to generate a navigation menu dynamically?
@burkedunnweb
Yes this should be possible.