Closed romanmarkelov closed 7 years ago
There is a module:
export default ($selector, options = {}) => { require.ensure([], (require) => { require('ion-rangeslider/css/ion.rangeSlider.css'); require('ion-rangeslider/css/ion.rangeSlider.skinFlat.css'); require('ion-rangeslider/js/ion.rangeSlider.js'); $selector.ionRangeSlider(options); }); };
initialize:
import slider from 'modules/slider'; slider('.slider', { hide_min_max: true, hide_from_to: true, keyboard: true, drag_interval: true, type: 'double', prefix: '', grid: false });
everything works fine! but when I write down the instance variable, method fails
let instance = $('.slider').data('ionRangeSlider'); instance.reset(); // Uncaught TypeError: Cannot read property 'reset' of undefined(…)
webpack config:
//... new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery", "window.jQuery": "jquery" }) //...
Hmm, try to add callback in to slider function, which will return the instance.
Also, please check, what is $('.slider') at the moment. Maybe your are trying to apply method before slider was initialized.
$('.slider')
There is a module:
initialize:
everything works fine! but when I write down the instance variable, method fails
webpack config: