[SOLVED] Repeater value does not appear on the code

I’ve been trying to add some data to a lightbox from a repeater to no sucess. The main issue is that the code seems not to recognize the value on the repeater (this value comes from a database).

The main issue occours as follows:

let a = $w ( ‘#text1’ ). text
console . log ( a )

#text1” is a textbox within the repeater. It displays the correct value from the database, but the console just shows the standard text: “Heading 4”. This happens to every textbox that’s on the repeater.

So when I add the rest of the code, my lightbox just displays the standard value.

“Chaveiro” = Value that comes from the database and appears on the Repeater;
“Heading 4” = Value that appears on the console, although it references the textbox.text that displays “Chaveiro”.

Any tips are welcome. Thanks in advance :slight_smile:

Looks like a classic example of global vs item scope. This should help you -

Good luck

Do you have a button within the repeater?

You have to use the event.context to get the items from the current selected container of your repeater.

Eg: if you have a button on your repeater then:

In my example I had a booking repeater. The booking repeater had a book button. I created a book button onClick() event. There I grabbed the details I needed from the repeater. In order to grab the details for the current repeater location that the user clicked the button on, I had to use the event.context.

export function buttonBook_click(event) {
    let $item = $w.at(event.context);  // get all items from current container where book button was pressed on

    // setup string of variables to be passed to next page
    let urlString = $item("#buttonBook").link+"?courseid="+$item("#textCourseID").text  + 
                         "&coursetitle="+ $item("#textCourseTitle").text + 
                         "&coursestartdate="+ $item("#textStartDate").text +
                         "&coursefulldate="+ $item("#textDisplayDate").text;

    let urllnk = $item("#textbuttonlink").text + urlString;
    console.log("Url set to: " + urllnk);
        

Thanks, Colin! Works perfectly.

The updated code:

Best Regards,

Paul,

There is a “Read More” button and it currently works. The blocking point was that it was not getting the currently displayed information on the repeater.

Thanks for the reply :slight_smile:

@murphyjaneway , sorry but I’ve got stuck once again on the same code:

The code regards a rating system on a repeater. The dataset of this repeater displays 4 items. Your solution above worked, so now I can get the rating from the rating input sucessfully.

The issue is that any of the 4 ratings inputs just returns the value to the first result on the datasheet.

For example: If I rate “Loja 1” as 4 stars and then rate “Loja 2” as 2 stars, those 2 stars go to the dataset of Loja 1.

Full code below:

Any ideas what might be causing this?

@leo7348 Hey - I would first delete the second onReady call at line 39, as the page is already loaded and some feel it can cause problems. Then, I’d add semicolons to terminate lines of code where appropriate - call me old-school (82 yo), but it helps me spot errors, like in query statements. This may not fix your problem but it’s a start…

@murphyjaneway , thank you very much for sharing your knowledge/wisdom :slight_smile:
The semicolons tip improved a lot the general code, plus now after quite a lot of changes, fixes and rewriting, the code is running as intended.

Best Regards,