NightCatSama / vue-slider-component

🌡 A highly customized slider component
https://nightcatsama.github.io/vue-slider-component
MIT License
2.42k stars 346 forks source link

Failed to load slider when using on Dynamic Component #82

Closed theromie closed 7 years ago

theromie commented 7 years ago

I am loading component dynamically like <component :is="currentView"></component> but slider range left and right stuck to 0. I also use :real-time property but doesn't worked. How can i reinitialize vueslider? <vue-slider ref="slider1" v-bind="price" v-model="price.value" :real-time="true"></vue-slider>

NightCatSama commented 7 years ago

this.$ref.slider1.refresh() can refresh the component.

theromie commented 7 years ago

Error in mounted hook: "TypeError: Cannot read property 'slider1' of undefined"

NightCatSama commented 7 years ago

oops, my apologies, it should be this.$refs.slider.refresh().

https://vuejs.org/v2/guide/components.html#Child-Component-Refs

theromie commented 7 years ago

This should be inside mounted()? because i am facing same issue

NightCatSama commented 7 years ago

After the component is rendered, then call this method.

theromie commented 7 years ago

No man not working

NightCatSama commented 7 years ago

You can see here can give you inspiration: https://jsfiddle.net/9pp3dqkq/54/

theromie commented 7 years ago

Dude onclick of refresh is not going to 100

NightCatSama commented 7 years ago

theromie commented 7 years ago

I am using getuikit and showing slider inside dropdown but dropdown failed to refresh vue slider

NightCatSama commented 7 years ago

Maybe you can try to listen for the shown event and call refresh later to refresh the component.

theromie commented 7 years ago

UIkit.dropdown(element).shown({ this.$refs.daysSlider.refresh(); }); Syntax Error: this is a reserved word

theromie commented 7 years ago

I also have updated your jsfiddle to work with dropdown of uikit Snippets

NightCatSama commented 7 years ago

https://jsfiddle.net/9pp3dqkq/94/

theromie commented 7 years ago

thanks its working

theromie commented 7 years ago

what if i want to do it like UIkit.dropdown(element).shown({ this.$refs.daysSlider.refresh(); });

NightCatSama commented 7 years ago

That's not the UIkit binding of events.

look it: https://getuikit.com/docs/javascript#programmatic-use

$('#offcanvas').on('show', function () {
    // do something
});