bqworks / slider-pro

A modular, responsive and touch-enabled jQuery slider plugin that enables you to create elegant and professionally looking sliders.
MIT License
877 stars 390 forks source link

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

Open nikocraft opened 7 years ago

nikocraft commented 7 years ago

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?

davidghi commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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