I have installed Views Slideshow 8.x-4.5 on Drupal 8.3.7 as well as the required dependancies as per the README file.

The slideshow that I have created works perfectly in the preview window at the bottom of the Structure > Views screen. However, when I add the block to the Header section of the front page, only the first slide is displayed as a static image. The following error is displayed in the Javascript console:

drupal.js:59 Uncaught TypeError: Cannot read property '#views_slideshow_cycle_main_slideshow-block_1' of undefined
    at HTMLDivElement.<anonymous> (views_slideshow_cycle.js:15)
    at Function.each (jquery.min.js:2)
    at n.fn.init.each (jquery.min.js:2)
    at Object.attach (views_slideshow_cycle.js:13)
    at Object.Drupal.attachBehaviors (drupal.js:160)
    at drupal.init.js:17
    at HTMLDocument.t (ready.min.js:4)

I have tried clearing the cache to no avail.

What is causing this please and how can it be resolved?

Comments

flamble created an issue. See original summary.

ziady’s picture

I ran into the same issue, with the following errors:

TypeError: drupalSettings.viewsSlideshowPagerFields is undefined
TypeError: drupalSettings.viewsSlideshowPagerFields is undefined

In my case, it was the use of the tag in the body of my slideshow node that was causing the problem. When I removed that tag, the slideshow worked again. I was able to replicate and correct this issue on my Dev and Production sites; I don't know enough about it to help with the underlying cause.

I found some info at https://drupal.stackexchange.com/questions/210984/how-to-fix-uncaught-ty...

The common error is the footer JS tags were wrapped in an additional HTML tag. In one commenter's case, it was the tag. In my case, it was a

. With the easy access to the theme layer via Twig, I am sure someone is going to run into the problem of "Don't wrap the Drupal footer JS tags in another HTML tag or all scripts will throw an error." This is a common problem identified by the OP's question. It is not broad at all. – Joe Hyde Dec 26 '16 at 5:28

lynettew’s picture

I've had a similar experience, but a different error. I'm on Drupal 8.4.0, and have installed Views Slideshow 8.x-4.5 with all libraries. Upon further inspection, the error I was getting was:

Uncaught TypeError: $(...).cycle is not a function
    at Object.Drupal.viewsSlideshowCycle.load (views_slideshow_cycle.js?oxwxjl:378)
    at Object.Drupal.viewsSlideshowCycle.imageWait (views_slideshow_cycle.js?oxwxjl:368)
    at HTMLImageElement.<anonymous> (views_slideshow_cycle.js?oxwxjl:321)
    at HTMLImageElement.dispatch (jquery.min.js?v=3.2.1:3)
    at HTMLImageElement.q.handle (jquery.min.js?v=3.2.1:3)

When I looked at the jquery.cycle.all.js file this is what it looks like:

Only local images are allowed.

If I take off the cache busting, the file reads perfectly normal. I have tried deleting the file and creating by copying pasting, I have deleted everything and created again, and I have tried creating the view with different show settings and block display settings just to see if anything of that sort would do anything. The file keeps displaying corrupted pretty much no matter what I do.

I'm going to try a few more things in the back end, and will let you know if anything works.

nickdickinsonwilde’s picture

Status: Active » Postponed (maintainer needs more info)

Do you still have an example available that's failing? - It *shouldn't* do that and I'm not sure what configuration would make it do that

streever’s picture

I have the same issue but it's local; it only happens on my subtheme of Bartik, but it works on Admin theme or if I change to Bartik.

OP, did it only happen to you in subtheme?

nickdickinsonwilde’s picture

Are you properly rendering the DrupalSettings JSON?

nickdickinsonwilde’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

If you give me more information about the theme, I can try to debug it further, but so far unable to reproduce.

adam3145’s picture

I am getting the same issue here is a link
http://master.doncampbell.actdev.ca/

Using bootstrap theme

adam3145’s picture

Status: Closed (cannot reproduce) » Active
marcel tuchek’s picture

Any solutions? Desperately looking for a solution.

Robhern135’s picture

Same issue here on multiple sites

Uncaught TypeError: Cannot read property 'homepage_slideshow-block_1' of undefined
    at HTMLUListElement.<anonymous> (views_slideshow.js?v=8.8.2:268)
    at Function.each (jquery.min.js?v=3.4.1:2)
    at k.fn.init.each (jquery.min.js?v=3.4.1:2)
    at Object.attach (views_slideshow.js?v=8.8.2:260)
    at drupal.js?v=8.8.2:25
    at Array.forEach (<anonymous>)
    at Object.Drupal.attachBehaviors (drupal.js?v=8.8.2:22)
    at drupal.init.js?v=8.8.2:28
    at HTMLDocument.listener (drupal.init.js?v=8.8.2:20)
neslee canil pinto’s picture

Can you please provide step to reproduce this issue. Thanks.

neslee canil pinto’s picture

Status: Active » Closed (cannot reproduce)
khaldoon_masud’s picture

To reproduce:
Create two view blocks within the same view with view id "bock_1" and "block_10". drupalSettings.viewsSlideshowCycle will create two indexes drupalSettings.viewsSlideshowCycle["views_slideshow_cycle_view_name-block_1-2] and
drupalSettings.viewsSlideshowCycle["views_slideshow_cycle_view_name-block_10]
instead it should be
drupalSettings.viewsSlideshowCycle["views_slideshow_cycle_view_name-block_1] and
drupalSettings.viewsSlideshowCycle["views_slideshow_cycle_view_name-block_10]
This causes the below error:

drupal.js?v=8.9.17:13 Uncaught TypeError: Cannot set property 'targetId' of undefined
    at HTMLDivElement.<anonymous> (views_slideshow_cycle.js?qwq0mk:15)
    at Function.each (jquery.min.js?v=3.5.1:2)
    at S.fn.init.each (jquery.min.js?v=3.5.1:2)
    at Object.attach (views_slideshow_cycle.js?qwq0mk:12)
    at drupal.js?v=8.9.17:25
    at Array.forEach (<anonymous>)
    at Object.Drupal.attachBehaviors (drupal.js?v=8.9.17:22)
    at drupal.init.js?v=8.9.17:28
    at HTMLDocument.listener (drupal.init.js?v=8.9.17:20)

It breaks the slideshow functionality.

khaldoon_masud’s picture

StatusFileSize
new788 bytes

Here is the patch for #14