Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't initialize slider pro after destroying previous instance of it #222

Open
nikocraft opened this issue Oct 7, 2017 · 5 comments
Open

Comments

@nikocraft
Copy link

I can destroy slider pro but can't later reinitialize it.

Here is my code:

this.el.data( 'sliderPro' ).destroy()

$('#sliderpro-'+this.uniqueId).sliderPro({
    width: this.width,
    height: this.height,
    arrows: this.arrows,
    buttons: this.buttons,
    waitForLayers: this.waitForLayers,
    fade: this.fade,
    autoplay: this.autoplay,
    autoScaleLayers: this.autoScaleLayers,
    imageScaleMode: this.imageScaleMode,
    loop: this.loop,
    touchSwipe: false
})

here is the error I get in the console:
Uncaught TypeError: Cannot read property '$slide' of undefined
at SliderPro._resetSlidesPosition (content_editor.js?kaCQ3Aj:194763)
at HTMLDivElement. (content_editor.js?kaCQ3Aj:194662)
at HTMLDivElement.dispatch (content_editor.js?kaCQ3Aj:9748)
at HTMLDivElement.elemData.handle (content_editor.js?kaCQ3Aj:9556)
at Object.trigger (content_editor.js?kaCQ3Aj:12743)
at jQuery.fn.init.triggerHandler (content_editor.js?kaCQ3Aj:12817)
at SliderProSlide.trigger (content_editor.js?kaCQ3Aj:195616)
at content_editor.js?kaCQ3Aj:195521
at Object.checkImagesComplete (content_editor.js?kaCQ3Aj:195789)
at SliderProSlide.resizeMainImage (content_editor.js?kaCQ3Aj:195517)
_resetSlidesPosition @ content_editor.js?kaCQ3Aj:194763

any ideas what is going on? Why should I not be able to create new slider pro after I destroyed a previous instance of it?

@nikocraft nikocraft changed the title can't initlize slider pro after destroying it can't initialize slider pro after destroying previous instance of it Oct 7, 2017
@davidghi
Copy link
Member

davidghi commented Oct 9, 2017

Hi. I can't replicate the issue. It's working well for me when I 'destroy' and then re-instantiate the slider in one of my examples.

It could be a problem in your setup... Is the error thrown when you destroy the slider or when you re-instantiate it?

@nikocraft
Copy link
Author

Hi David

when you tested it did you test in vanila js or with vuejs? I'm trying to use it with vuejs and thats where its not working. I thought by doing this I'd be able to get slider pro to pick up any changes I have made.

@davidghi
Copy link
Member

davidghi commented Oct 9, 2017

I tested in vanila JavaScript. Are you sure the issue is vuejs related and not something else in your setup? Please try to replicate the same functionality in plain JavaScript.

@nikocraft
Copy link
Author

nikocraft commented Oct 9, 2017

will try, but it will probably work in plain javascript since slider pro is made to work with it. but anyways if we do not solve it, I'll just build simple vue based slider in the backend and let the user pick if they want it rendered with slider pro in the frontend or some other slider like slick slider for example.

@Mayocampo
Copy link

Any news on this?. Slider keeps failing after destroy it or when its parent is hidden

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants