dynamic item page - gallery picture load problems

Update:

When I re-design the page to use simple ‘image’ elements (instead of a gallery) that pull from the dataset, and remove the code above that loads a ‘gallery’ element, everything works fine. No problems with a page refresh or sending just the dynamic page URL to someone - it works perfectly.

At this point I tend to think there is some sort of permissions inheritance that allows:

import wixData from ‘wix-data’;
$w.onReady( function () {

to work when the invoked by the inventory page, but will not work when you do a page refresh on the dynamic item page.

Anyone know anything about the permissions required for ‘import’ and ‘onReady’?

Unfortunately using only image elements instead of a gallery element doesn’t work, apparently a gallery element has more advanced image handling capabilities.