Dynamic Content and Autoplay

mail's Avatar

mail

14 Oct, 2016 01:26 PM

Hi

I want to use the slider in an angular/ ajax app. And I encountered a problem when switching all slides dynamically while Autoplay is enabled sometimes it throws a TypeError: Cannot read property 'isLoaded' of undefined.
If I turn autoplay off everythings works fine.

My Programflow is the following:

Create slides array with html and angular directives
then destroy slider if exists
then initialize slider with new slides

  function initSlider(){
            destroySlider();
            $timeout(function(){
                slider = $("#result-list-slider").royalSlider({
                    slides:slides,
                    keyboardNavEnabled: true,
                    autoPlay: {
                        enabled: true,
                        delay:3000
                    },
                    slidesSpacing:0,
                    minSlideOffset:0
                }).data('royalSlider');
            })
        }

function destroySlider(){
            if(slider){
                $("#result-list-slider").royalSlider("destroy").empty();
                slider = undefined;
            }
        }

  1. Support Staff 1 Posted by Dmitry Semenov on 14 Oct, 2016 05:49 PM

    Dmitry Semenov's Avatar

    Hello,

    Are you sure that slider is defined when you call destroySlider method. The plugin clears autoplay timeouts on destroy, very strange, try also calling stopAutoPlay method before the destroy.

    Dmitry

  2. 2 Posted by mail on 17 Oct, 2016 06:50 AM

    mail's Avatar

    Thanks for fast reply I think I found the reason it happens when slides array is empty. Tough it doesn't throw errors when autoplay.enabled = false;

  3. mail closed this discussion on 17 Oct, 2016 08:47 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac