Issue with destroy not working

Christian's Avatar


01 Nov, 2021 02:06 PM

Hi Dimitry,

I'm using enquire.js to initialise RoyalSlider for mobile, but then I want it to be destroyed when on desktop.

For mobile (when the media query is matched), I have the below code:

                        transitionType: 'fade',
                        controlNavigation: 'none',
                        arrowsNav: false,
                        slidesSpacing: 0,
                        imageScalePadding: 0,
                        loop: true,
                        numImagesToPreload: 0,
                        autoPlay: {
                            enabled: true,
                            stopAtAction: false,
                            pauseOnHover: false,
                            delay: 2500

When it's for desktop (unmatched) I have the below call:


Royal slider correctly initialises when matched (mobile), but the destroy command doesn't seem to fire when unmatched (desktop). What am I doing wrong?

  1. Support Staff 1 Posted by Dmytro Semenov on 01 Nov, 2021 02:44 PM

    Dmytro Semenov's Avatar


    destroy() doesn't remove the element from DOM, it just unbinds events and clears timers. It also doesn't restore the element to its original state. Is this why you think that it's not working? Please elaborate.

  2. 2 Posted by Christian on 01 Nov, 2021 02:48 PM

    Christian's Avatar

    Hi Dmitry,

    Okay it sounds like I'm misunderstanding the use of destroy(). How then would I go about removing the Royal Slider and restoring elements to their original states?

  3. Support Staff 3 Posted by Dmytro Semenov on 01 Nov, 2021 03:31 PM

    Dmytro Semenov's Avatar

    You may store the initial markup of the slider in some variable before it's initialized. And then insert it back when you need to create a new instance.

  4. 4 Posted by Christian on 01 Nov, 2021 05:46 PM

    Christian's Avatar

    Ok thanks Dmitry I'll give that a try.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? 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