How to work with anchor and database ?

Nothing of these work

SimpleThingMakesFuckingConfusion


You can do it as page links through the use of rich text field as shown here from Tal (Wix Mod) in this previous post.
https://www.wix.com/corvid/forum/community-discussion/url-field-type

Or do it like this example here from Massa (Wix Mod)
https://www.wix.com/corvid/forum/community-discussion/set-button-link-to-different-anchor-located-in-a-repeater-connected-to-a-dataset

And “/path#anchorPropertyId” does work (for relative link)

Hi @jonatandor35 , where i can get the #anchorPropertyId ?

@jonatandor35 omg its really working /why-us#text42 … this is very simple and onpoint solutions i’ve ever got in this forum

@jonatandor35 i have one more question, do you know how to target the #propertyid inside specific repeater ?

in this case, my #text42 is from database that loaded into repeater
my #text42 is Survey, Design, Review like in picture bellow…

i’ve tried to add number after property id like “/path#propertyid[1]” not working…

@sajati you’ll need to write some code for that and to use url query params instead of hash. I already posted an answer for a similar question before, but I don’t have time to elaborate right now. I’ll try later today (unless someone else will write it first).

As J. D. says, you can get the basic understanding from Wix API reference for Wix Location for url info and Repeater for scope details and onItemReady etc.
https://www.wix.com/corvid/reference/wix-location.html
https://www.wix.com/corvid/reference/$w.Repeater.html

You can also see previous posts about similar from Yisrael and Steve that should keep you going until J. D. gets back to you.
https://www.wix.com/corvid/forum/community-discussion/repeater-open-link-in-same-window
https://www.wix.com/corvid/forum/community-discussion/wixlocation-to-does-not-work-in-a-repeater-object

Well, there’re more than one way to do it, and each way has its own pros & cons. I’ll post it one option:
So you need -

  1. to pass the item ID to the page
  2. to scroll to the item with this ID

The relevant ID here is not the graphic element property ID, but the data item id as appear in your collection (It’s a hidden field by default but you can make it visible if you want).

The URL will be " /path?item= " + the item data ID .
For example:
/survey?item= 345-6788-4531-9b0e-e779ae9bdbcd

Then on the survey page:

import wixLocation from 'wix-location';//must be at the top of the page code.

let targetItem =  wixLocation.query.item;
function scrollToRepeaterItem(itemId){
    if(itemId !== undefined){
    $w("#repeater1").forItems( [itemId], ($item, itemData, index) => {
$item("#text42").scrollTo();
    })
    }
}

//then you can call this function when the page and datasets are ready:
$w.onReady(function () {
$w("#dataset1").onReady( () => {
scrollToRepeaterItem(targetItem);
})
})
//You can also call this function on button click or whatever you like.

Note: this scrolling might be in conflict with page transition animation if you have one. So take it into account.