Add or remove handles dinamically
See original GitHub issueI’ve been trying to dynamically update the slider adding range sliders at the (click) event, but nothing seems to happen.
HTML
<nouislider (change)="sliderChangeSun($event)" [config]="configSliderSun"></nouislider>
<div (click)="addHandle()" class="add"></div>
TS
configSliderSun: any = {
start: [0, 15],
connect: [false, true, false],
range: {
'min': 0,
'max': 24
}
addHandle() {
this.configSliderSun.start.push(20, 35);
this.configSliderSun.connect.push(false, true, false);
}
What’s wrong in the approach I’m using? The array gets updated according to console log, but the range slider doesn’t update.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
jquery slider with multiple handles (dynamically add and ...
Have ONE slider with a fixed lower-value to 0 and with at least two handles, where the user can add and remove handles...
Read more >Dynamically add and remove user controls - CodeProject
I'll show you how to do that, how to remove user controls, and also how to access the values of the controls within...
Read more >Add and remove event handlers dynamically in VB.NET
.NET lets you add and remove Event Handlers dynamically on the fly. Your code can start and stop handling events at any time...
Read more >Add or remove input fields dynamically with React - YouTube
Add or remove input fields dynamically with Reacthttps://www.cluemediator.com/ add-or-remove -input-fields- dynamically -with-reactjsREACT ...
Read more >React: Add/Remove Input Fields Dynamically on button click
My React Portfolio Course: https://chaoocharles.gumroad.com/l/react-portfolio-courseSource Code/Starter Files: ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Unfortunately , this option is not support by
updateOptions
, so you need toslider.noUiSlider.destroy()
and create a new one.Ref doc: https://refreshless.com/nouislider/more/#section-update
I`m trying to implement a range slider with ng2-nouislider into a reactive form.
I also want to add or remove handles dynamically.
I have a reactive form in my project and it is not possible for me to change to a template driven one.
Here is my stackblitz for the ngmodel variant that works like I want:
https://stackblitz.com/edit/ng2-nouislider-with-form-8vbrt4?file=src/app/app.component.html
And here is the stackblitz for the reactive form variant:
https://stackblitz.com/edit/ng2-nouislider-with-form-g8zpq4?file=src/app/app.component.html
In this documentation it sais the nouislider component has to be destroyed to add new handles:
https://refreshless.com/nouislider/more/#section-update
But I tried it also without destroy via the destroy method of nouislider in the ngmodel variant and it worked also well. The destroy via the if condition seems to be enough.
My problem is in the reactive form variant. If you try this example and push the plus button, you can see, that the handle is added, but the forms value is not correct after the reinitialization of the slider in the dom.
The value seems to be only for a short time correct, and then the array loses the last value. In other words. If the value is [33,66] and should be [25,50,75] after the button click, the value is only very short correct, and the it is only [25,50].
It seems that the slider is not really destroyed and remembers the old array length of the start value. And after reinitialization it overrides the form value again.
So please…
Is anybody able to help me here? I can not see any error in my code here. Thanks in advance =)