Back button on dynamic item page to repeater page.

I’ve searched all over for a solution for me & haven’t found exactly what I’m looking for.

I have a dynamic repeater page that displays job listings. When a nurse clicks on a job listing, it will take them to a dynamic item page that displays the details on the job they clicked on. I have a back button on the detailed page, and when you click it, it takes you back to the dynamic repeater page (page 1) every time. Same with the browser back button.
I’m looking for a code that would make the back button return to the repeater page that they were originally on, instead of always returning to page 1.

I followed the code that Yisrael posted here:

Unfortunately it didn’t work for me. The code is working, but now when you click the back button on the detailed view page, it takes you to the ITEM that you previously viewed (so another detailed dynamic item page) instead of the dynamic repeater page.
I can’t have that, so the site is back to the action of returning to page 1 of the repeater.

You can view the dynamic repeater page here. If you click on a listing (let’s say from page 3) you can then see the back button and how if you click it, it will take you back to page 1 of the repeater. I’d love to code it so that the dropdown inputs stay the same on the back button action too, but mainly just want it to return them to the repeater page they were on.

Any help is appreciated! Thanks!

Hi! :slight_smile:

On the dynamic repeater page:

import wixLocation from 'wix-location';

export function repeater1_itemClick(event) {
  // Get the page number from the event object
  const pageNumber = event.context.page;

  // Navigate to the dynamic item page, including the page number as a query parameter
  wixLocation.to(`/dynamic-item-page?page=${pageNumber}`);
}

On the dynamic item page:

import wixLocation from 'wix-location';

export function backButton_click(event) {
  // Get the page number from the query parameter
  const pageNumber = wixLocation.query.page;

  // Navigate to the dynamic repeater page, including the page number as a query parameter
  wixLocation.to(`/dynamic-repeater-page?page=${pageNumber}`);
}

On the dynamic repeater page:

import wixLocation from 'wix-location';

$w.onReady(() => {
  // Get the page number from the query parameter
  const pageNumber = wixLocation.query.page;

  // Set the page property of the repeater to the page number
  $w('#repeater1').page = pageNumber;
});

Still not working for me, but I also failed to mention that the pages of my repeater are run by a pagination bar (#pagination1). This definitely gives me a better idea of what I need though! Can you expand your knowledge knowing the pagination is in place now?

When “setting the page property of the repeater to the page number” it doesn’t recognize page as a property. Not sure if that has to do with the pagination or if it should still work regardless it showing me the error.