Corvid Tutorial: Creating a Show-More Link DOES NOT WORK

I have done every thing it tells me to do but I cant get it to work at all!!! Help me!

https://gyazo.com/7e44d34f3c4aba7cf811d33f7a0007cd

Paste all your code that you have used as that code from the tutorial does indeed work correctly.

If you are using a dataset for your text then you need to follow the dynamic text parts of it and not follow the static parts of the tutorial.

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) {
// 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) {
// 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";
}
}

// For full API documentation, including code examples, visit Velo API Reference - Wix.com 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(" #text1 “).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(” #text1 ").text = shortText; //TODO: write your page related code here… }); Nothing works

@deleteduser
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(“#text1”).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(“#text1”).text = shortText;
});

@deleteduser Get off my lawn!

lmao

Can I get help?

Only if you post details about what’s going on, and post your entire code. I only wish I were a mind-reader.

@skmedia i did

@cannon In that case, you need to continue with the tutorial first. As of right now, no part of your code is triggering the show more, and in order for the code to work, you need to actually type what you want the text to say into the code panel and set it equal to the full/short text variables respectively.

@skmedia If you look at the like provided you will see I dont have the 40 characters
I should have

@cannon Disregard that last comment. You need to tie your button to the code, like in what whiskey posted.

@skmedia So what do I need to do to fix it.

@cannon Read whisky’s post, especially the lower half. It explains everything in detail. And make sure you check the onClick option in the properties panel for your button.

@skmedia
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(“#text1”).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(“#text1”).text = shortText;
});

export function button1_click(event) {
// check the contents of the text element
if ($w(“#text1”).text === shortText) {
// if currently displaying short text, display the full text
$w(“#text1”).text = fullText;
$w(“#button1”).label = “Show less”;
} else {
// if currently displaying full text, display the short text
$w(“#text1”).text = shortText;
$w(“#button1”).label = “Show more”;
}
//Add your code for this event here:
// display the full text
$w(“#text1”).text = fullText;
// collapse the button
$w(“#button1”).collapse();
}

Still does not work

@cannon Did you check the onClick in the button’s property panel? Also, what is the name of your elements in the editor when you select them?

@skmedia no text at all is showing

@cannon

Make up your mind of which option you want, either the show more link or the show more/show less toggle as you have both in your bottom half of code.

Like David said earlier, go back to the tutorial and look at the part of controlling it and follow it for whichever option you are wanting.
https://support.wix.com/en/article/corvid-tutorial-creating-a-show-more-link#part-3-controlling-the-button

@givemeawhisky Both should be there it is a if else