TEXTO ESTATICO - copie el cocigo tal cual dicen de https://support.wix.com/en/article/corvid-tutorial-creating-a-show-more-link y sustitui, el nombre del boton con el mio (button1) y del texto con el mio (text5) pero no me funciona y me da el siguiente error TEXTO NO DEFINIDO
Av er si pueden ayudarme, les paso el codigo
---------------------
let fullText; // variable to hold the full text let shortText; // variable to hold the short version of the text $w.onReady(function () { // how many characters to include in the shortened version const shortTextLength = 40; // read the full text and store it in the fullText variable fullText = $w(#text5).text; // grab the number of characters defined in shortTextLength and store them in the shortText variable shortText = fullText.substr(0, shortTextLength) + "..."; // set the contents of the text element to be the short text $w(#text5).text = shortText; }); // check the contents of the text element if ($w(#text5).text === shortText) { // if currently displaying short text, display the full text $w(#text5).text = fullText; $w(#Button1).label = "Show less"; } else { // if currently displaying full text, display the short text $w(#myText5).text = shortText; $w(#Button5).label = "Show more"; } export function button1_click(event) { //Add your code for this event here: // display the full text $w(#Text5).text = fullText; // collapse the button $w(#Button).collapse(); }
------------------
gracias
Also, make sure that you choose one option of the show more button of the show more/show less toggle and not both of them.
Code for the "Show More" Button
let fullText; // variable to hold the full text let shortText; // variable to hold the short version of the text $w.onReady(function () { // how many characters to include in the shortened version const shortTextLength = 40; // read the full text and store it in the fullText variable fullText = $w("#myTextElement").text; // grab the number of characters defined in shortTextLength and store them in the shortText variable shortText = fullText.substr(0, shortTextLength) + "..."; // set the contents of the text element to be the short text $w("#myTextElement").text = shortText; }); export function mybutton_click(event, $w) { //making sure that you have added the onClick event in properties // display the full text $w("#myTextElement").text = fullText; // collapse the button $w("#myButton").collapse(); }
Code for the "Show More/Show Less" Toggle Button
let fullText; // variable to hold the full text let shortText; // variable to hold the short version of the text $w.onReady(function () { // how many characters to include in the shortened version const shortTextLength = 40; // read the full text and store it in the fullText variable fullText = $w("#myTextElement").text; // grab the number of characters defined in shortTextLength and store them in the shortText variable shortText = fullText.substr(0, shortTextLength) + "..."; // set the contents of the text element to be the short text $w("#myTextElement").text = shortText; }); export function mybutton_click(event, $w) { //making sure that you have added the onClick event in properties // check the contents of the text element if ($w("#myTextElement").text === shortText) { // if currently displaying short text, display the full text $w("#myTextElement").text = fullText; $w("#myButton").label = "Show less"; } else { // if currently displaying full text, display the short text $w("#myTextElement").text = shortText; $w("#myButton").label = "Show more"; } }
All forum posts need to be in english only.
Your issue is that you are simply missing code from your element id names.
Your code
$w(#Button).collapse();
Tutorial Code,,,,
$w('#myButton').collapse();
You notice what you have missed off all of your element names in the code?