I want to open add on click funtion in repeater item

https://www.ico-offer.com/home

I want to open in window when click on view button in repeater in ioc offer section
also i want to show only some text of description not all on list

i tried


but i dont able to find results

1 Like

You will need to learn about how to modify the contents of each item inside a repeater. Look at this from the Reference API Docs. I modified it for you.

$w("#myRepeater").onItemReady( ($item, itemData, index) => {
  const repeatedText = $item("#repeatedText");
  const repeatedButton = $item("#repeatedButton");

  repeatedButton.label = "View";
  repeatedText.text = itemData.description.substring(1, 50); // Will show only the first 50 characters from the text

  repeatedButton.onClick( (event) => {
    wixLocation.to("url here to open");
  } );
} );

can i add show and hide buttons like show more to view full text else collapse

also view button is connected to database url

Hey
If you want a View More button, add a button inside the item of the repeater and also another text field which will hold the full text. Switch between then with collapse and expand to make it look good using the below code.

$w("#myRepeater").onItemReady( ($item, itemData, index) => {
 const repeatedText = $item("#repeatedText");
 const repeatedButton = $item("#repeatedButton");
 const repeatedFullText = $item("#repeatedFullText");
 repeatedButton.label = "View";
 repeatedText.text = itemData.description.substring(1, 50); // Will show only the first 50 characters from the text
 repeatedFullText.text = itemData.description;
 
 repeatedButton.onClick( (event) => {
 wixLocation.to("url here to open");
    } );

 viewMoreButton.onClick( (event) => {
 repeatedText.collapse();
 repeatedFullText.expand();
      } );
  } );

hey but repeated view button is connected to databse url it changes as per title