i want users to click on one item in repeater page and then direct them to a dynamic page and show data of selected item at that place,
may you help me?:) please help if you know very greatfull if i know it thanks
Important forum update
This forum is migrating to one unified Wix community forum starting July 26th, and will be read-only during the process.
Wishlist Page is the official platform for requesting new features. You can vote, comment, and track the status of the requested features.
Hi, First you need to get the current Item onClick, then to use these data to redirect the page to that item's dynamic page. So your code should look something like this :
$w("#ItemContainer").onClick( (event, $w) => { let targetId = $w("#dataset1").getCurrentItem()._id; wixLocation.to('/dynamicPage/'+ targetId) // } );
Note that i used the id to be the page Title ( Path ) . Hope this helps! Best, Mustafa
can anyone please tell me whats wrong here? why is that "Done" button locked?
Good to know. But my page (at least Preview mode) seems to be confusing the two :(
I don't understand how it's happening either, and I'm not sure how the data is stored. They're separate pages, but I copied the one and just changed the info. :( I'll keep backing out when Preview mode starts switching between the two with "next" or "previous." It just means I can't do my usual OCD fiddling with the placement of text and boxes :(
Well, damn. Both of my datasets are by default "dataset1" and as I'm just playing with the formatting, moving around buttons, it's making a mess of things. The "next" button is taking it to the other dataset and dynamic page.
Do you have any thoughts on this? I just keep undoing my changes and trying again.
Googling this topic it says you can't rename a dataset :(
It worked like a charm! The Mobile Story Time kits you helped me with are the first link. The second link is our new STEM Backpack collection. Not super-fancy, but I thought I'd share. Thanks again, J.D. :) https://www.keokuklibrary.org/youth-collections
Hallelujah - it works!!! Thank you so much, J.D.!!!
I think I'll be able to recreate this for another special collection, thanks to you <3 <3 <3
add })}) after this line: wixLocation.to(itemData["link-mobilestorytimekit-Kit-Info-title"]);
I'm sure I mangled your instructions! Can you tell me what's wrong with this picture?
import wixLocation from 'wix-location'; import {local} from 'wix-storage'; const linkField = "link-mobilestorytimekit-Kit-Info-title"; // replace this value $w.onReady(function () { $w("#dataset1").onReady(() => { const numberOfItems = $w("#dataset1").getTotalCount(); $w("#repeater1").onItemReady( ($item, itemData, index) => { $item("#text47").onClick( (event) => { wixLocation.to(itemData["link-mobilestorytimekit-Kit-Info-title"]); $w("#dataset1").getItems(0, numberOfItems) .then( (result) => { const dynamicPageURLs = result.items.map(item => item[linkField]); local.setItem('dynamicPageURLs', dynamicPageURLs); } ) .catch( (err) => { console.log(err.code, err.message); } ); } ); })
It doesn't like the punctuation at the end, that's for sure.
So sorry! And I've been googling wixLocation and nothing tells me what this means. I'm supposed to import something?
I have a dataset with multiple Story Time kits, with: kit name, image, short description, and long description. We have about 14 of these kits right now.
I have a page with a repeater that has the list of kits, names, and short descriptions.
When you click an image on the repeater it opens a dynamic page with the name, a larger image, short description, and a long description. Only the image will link to a dynamic page with the usual Wix tools.
I asked Wix how to make a next and previous button on the dynamic page for each kit, and they sent me a bunch of links. I tried everything until those buttons worked. I also asked Wix how to make this link I'm trying to make now, but they didn't understand the question when I referred to it as "Read More."
Visual aid:
https://www.keokuklibrary.org/mobile-story-time
I really do appreciate you trying to help.
I thought that maybe I misunderstood, so I changed to this, but still no dice:
import {local} from 'wix-storage'; const linkField = "link-mobilestorytimekit-Kit-Info-title"; // replace this value $w.onReady(function () { $w("#dataset1").onReady(() => { const numberOfItems = $w("#dataset1").getTotalCount(); $w("#dataset1").getItems(0, numberOfItems) .then( (result) => { const dynamicPageURLs = result.items.map(item => item[linkField]); local.setItem('dynamicPageURLs', dynamicPageURLs); } ) .catch( (err) => { console.log(err.code, err.message); } ); } ); } );
$w("#text47").onClick( (event, $w) => { let targetID = $w("#dataset1").getCurrentItem()["link-mobilestorytimekit-Kit-Info-title"]; 'wixLocation.to(targetID);' // } );
Like this:
$w("#text47").onClick( (event, $w) => { let targetID = $w("#dataset1").getCurrentItem()["link-mobilestorytimekit-Kit-Info-title"]; wixLocation.to('wixLocation.to(targetID);'+ targetID) // } );
That didn't work either :(
And there were these errors:
There was an error in your script The element selector function (usually $w) cannot be used before the page is ready
I successfully coded the next and previous buttons on the dynamic page, so this is everything on that page, if that makes a difference (?):
import {local} from 'wix-storage'; const linkField = "link-mobilestorytimekit-Kit-Info-title"; // replace this value $w.onReady(function () { $w("#dataset1").onReady(() => { const numberOfItems = $w("#dataset1").getTotalCount(); $w("#dataset1").getItems(0, numberOfItems) .then( (result) => { const dynamicPageURLs = result.items.map(item => item[linkField]); local.setItem('dynamicPageURLs', dynamicPageURLs); } ) .catch( (err) => { console.log(err.code, err.message); } ); } ); } );
$w("#text47").onClick( (event, $w) => { let targetID = $w("#dataset1").getCurrentItem()["link-mobilestorytimekit-Kit-Info-title"]; wixLocation.to('wixLocation.to(targetID);'+ targetID) // } );
Thoroughly confused.
After J.D.'s post I tried a few things. The latest:
$w("#text47").onClick( (event, $w) => { let targetID = $w("#dataset1").getCurrentItem()["link-mobilestorytimekit-Kit-Info-title"]; wixLocation.to('/dynamicPage/'+ targetID) // } );
I still don't know if I'm supposed to change "wixLocation" and what I'm supposed to type in its place.
And targetID - that's another one I'm not sure of.
#item container is the name of the button "Read More"
I changed "link-title" to my field key
Is there a spelling error? Something else I'm missing?
Am I supposed to do something on the dynamic page side?
Why is there a "Read More" button on this repeater Wix? Wix tech support will not help me - they sent me here instead.
Well, that didn't do it, but I'm out of time today. I'll try again tomorrow - thank you!
Is the last "targetId" supposed to be the button # also?
Sorry - I took web design classes almost 20 years ago :(
Points for speed! But ... it didn't work :(
$w("#text47").onClick( (event, $w) => { let targetId = $w("#dataset1").getCurrentItem()._id; wixLocation.to('/dynamicPage/'+ targetId) // } );
Hello! I am trying to do the same thing. My repeater has the words "Read More" and no pre-programmed way to link it to the dynamic page. Only the images link to the dynamic page.
I copied and pasted Mustafa's example above.
The only thing I changed was "#ItemContainer" to "#text47" (button name). Is that correct?
It's not working. The only error appears to be: "wixLocation" is "undefined."
Am I supposed to change wixLocation to the Field Key? How do I point to the page?
Hello,
@Mustafa Hammouz I have the same issue, but have no idea how to code it to get it to work... can you help me please? My website is www.maidstonelabour.com, and the repeater page is from the Menu: Key People: Councillors & Candidates (www.maidstonelabour.com/2019-council-candidates) I'd like to be able to click on the image in each repeater and for the user to be taken to the dynamic page that corresponds to that person's biography page, which is located in the dataset connected in that page...
Cheers,
Jessica
thanks, i'm so happy ;)