8
Views
8
Comments
Solved
Cannot read property '-1' of undefined error for Carousel widget
Service Studio Version
11.10.7 (Build 37468)

I am getting a "Cannot read property '-1' of undefined" error for Carousel widget.


I have a local variable which is type list of Images. (E.g. BusinessImages)

Based on an image which a user uploaded, I went to assign the uploaded image to the local variable.

For the carousel widget, I put the list source as my local variable.

Within the widget, there is an image placeholder and assigned the source E.g. BusinessImages.imageData.

When I test in my browser, the area where the carousel widget is supposed to be is empty, and if I click on that area, the error pops up.


Any idea what went wrong?

Screenshot20210131184925.jpg

Rank: #541
Solution

Hi SL,

On the OnInitializer event of the screen, you can append a NullBinary() on the image list. The default image will be shown for that and the error will not happen again.

The drawback of this solution is that you will have to remove the blank imagem when you add the first real image.

Rank: #56

Hi Kadu,


Wouldn't it be best to in that case not display the carousel if the image list is empty?


In this case, you don't display anything and it is a more "clean" solution and easy to maintain.

Regards,
João

Rank: #541

Hi João,

Indeed, this seems to be a better solution. SL can put that If and, whether it is necessary, put a default image on the false branch. Thus, it will not need to handle issues on the list.

Nice thinking.

Regards

Rank: #541

Hi SL,

I haven't understand your construction. Could you please post the oml file or a print of you Widget tree?

Regards

Rank: #5578

Hi I just edited the post with an image of the widget tree

Rank: #541

I have made a test here and I got the same error as you when my Carousel is empty. I've tried using it with and without a list and the error message is the same.

Rank: #56

Hi SL,


Can you confirm that your List inside CarouselItems has the variable BusinessImages and has the attribute disable-virtualization to True

Rank: #5578

Hi Joao, yes for the above. I just tried setting disable-virtualization to False and the carousel widget does appear :)


However, the images still do not appear in the carousel:

Rank: #541
Solution

Hi SL,

On the OnInitializer event of the screen, you can append a NullBinary() on the image list. The default image will be shown for that and the error will not happen again.

The drawback of this solution is that you will have to remove the blank imagem when you add the first real image.

Rank: #56

Hi Kadu,


Wouldn't it be best to in that case not display the carousel if the image list is empty?


In this case, you don't display anything and it is a more "clean" solution and easy to maintain.

Regards,
João

Rank: #541

Hi João,

Indeed, this seems to be a better solution. SL can put that If and, whether it is necessary, put a default image on the false branch. Thus, it will not need to handle issues on the list.

Nice thinking.

Regards