.Collapse() Promise is not resolved

Hello everyone,

I have an issue in my code with the .collapse() built-in function, that makes it not returning the result that it should resolve.

for example:
Let’s assume we have four elements ( case1 , case2 , case3 and case4 ), all of them are set to be Collapsed on load , except the third case case3 .

if ($w('#case1').collapsed === false) {
    $w('#case1').collapse.then( () => {
        console.log("Case 1 Collapsed");
        });
} else {
console.log('Case 1 is already collapsed');
}

if ($w('#case2').collapsed === false) {
    $w('#case2').collapse.then( () => {
        console.log("Case 2 Collapsed");
        });
} else {
console.log('Case 1 is already collapsed');
}

if ($w('#case3').collapsed === false) {
    $w('#case3').collapse.then( () => {
        console.log("Case 3 Collapsed");
        });
} else {
console.log('Case 1 is already collapsed');
}

if ($w('#case4').collapsed === false) {
    $w('#case4').collapse.then( () => {
        console.log("Case 4 Collapsed");
        });
} else {
console.log('Case 1 is already collapsed');
}

The expexted result is:

Case 1 is already collapsed
Case 2 is already collapsed
Case 3 Collapsed
Case 4 is already collapsed

But instead I get these results:

Case 1 is already collapsed
Case 2 is already collapsed

And that’s it. The third case promise is not being resolved.

Can anyone point where the issue is?

Many thanks in advance.

You’re missing parenthesis.
It should be: .collapse ()

Thank you for your quick reply @jonatandor35 :blush:

I did notice them after writing this example, but the original code does include them.


For some reasons, the issue was solved by itself, I also start getting some warnings that I didn’t get before.

Here is the warning message:

@ahmadnasriya somewhere you’re trying to assign an empty src to the image placeholder. Maybe you connected the image to a a dataset and the image field of 1 or more rows is empty.

Thanks a lot @jonatandor35 - Issue solved!

The src is only assined to the image if it’s field is not empty, this way I avoid getting the warnings like this one.

So on the dynamic page, I didn’t connect the image to the dataset, but instead, the image will only connect if it has a value in the database.

The issue was raised because of a syntax error inside the if statement that checks the above condition.

@jonatandor35 That error:

Wix code SDK error: The “src” property cannot be set to “”. It must be a valid image URL starting with “http://”, “https://” or “wix:image://”, or a valid video URL starting with “wix:video://”.

Is it because I assigned the src of the image to a link that starts with " image://.jpg " from my database?

@ahmadnasriya maybe,