Can't get a button link with velo on dynamic page

Question:
I’m trying to read and console log the link of a button on dynamic page.
using this documentation

this is my code:
console.log($w(“#button8”).link);
it works on non dynamic page and does not work on a dynamic page. any idea?

i run this code on

$w.onReady(function () {
console.log($w(“#button8”).link);
});

if i run the same code on

export function button8_mouseIn(event) {

console.log($w("#button8").link);

}

it works.
any idea why i cant get t he links on page ready function ?

Product:
wix studio

DYNAMIC-PAGE —> means —> you are using a DATASET !

Using a DATASET —> means —> You will first need to wait for page and DATASET to be ready, first —>

$w.onReady(()=>{
    $w('#dynamicDataset').onReady(()=>{
        ....now here you can start your codings......
    });
});

Furthermore —> a DYNAMIC-DATASET —> means always just one ITEM will be loaded at same time.

How to get the current dynamic item ?

$w.onReady(()=>{
    $w('#dynamicDataset').onReady(()=>{
       let curItem = $w('#dynamicDataset').getCurrentItem(); console.log('Current-Item: ', curItem);
    });
}

Thanks Dima!
and if have few items in the dynamicdataset, how do i check all of them ready?

Just to make clear your problem.

  1. You have a DATABASE where you store all of your data, right?
  2. Now you have created a page and turned it into a DYNAMIC one (using a DATASET → dynamic-Dataset).
  3. But what exactly is a → Dynamic-Page ? Well a dynamic-page is nothing else then a page, which loads all it’s informations out of your database → but it loads always just ----> 1 <------ item at once.

So, how do you regulate next or previous ITEM on your dynamic page?

Do you have a PREVIOUS and NEXT button on your dynamic page?

If you have only 1x button —> ‘button8’ on your page, and you want to load it’s LINK dynamically, when exactly should the link be loaded to the button ?

a) when the button itself has been clicked? → i don’t think you want that.
b) directly when item is ready loaded? – > maybe.

So i gave you some example code…

$w.onReady(()=>{
    $w('#dynamicDataset').onReady(()=>{
       let curItem = $w('#dynamicDataset').getCurrentItem(); console.log('Current-Item: ', curItem);
    });
}

Did you test it?
Did it work for you ?
Did you check the CONSOLE ?

…and if have few items in the dynamicdataset, how do i check all of them ready?

  1. you do not have the data (items) inside your dataset! → your items are inside of your database (collection) → the dataset is just somekind of element which connects your database with your page making your page → DYNAMIC (because now it is loading data from DATABASE —> This way you can create 1000 of pages with the data out of your DB.

  2. To check all the items directly on your dynamic page → you will need next and previous buttons, which will switch to NEXT or PREVIOUS item inside of your database.

  3. If you want to show all items at once inside somekind of a list (listing) —> you can use a TABLE or a REPEATER. → you will have to place a repeater or table onto your dynamic page connecting it with a new DATASET → NON-DYNAMIC → because we remember → DYNAMIC —> means —> 1x item at once which can be shown out of our DB (dynamic dataset / dynamic page) !

Dima Thanks a lot i figured everything out with your help

1 Like

Don’t forget to mark it as SOLUTION, if you found your solution.
Which of the provided SUGGESTIONS leaded you to your SOLUTION ?

—> Mark it <— :joy: