So I'm using this Foundation slider: click for doc. In order to access slider's current value they recommend using hidden input like so:
<div class="slider" data-slider data-initial-start="50" data-end="200">
<span class="slider-handle" data-slider-handle role="slider" tabindex="1">
</span>
<span class="slider-fill" data-slider-fill></span>
<input type="hidden">
</div>
What I want to do is display the value next to the slider using some variable. My idea is to listen to changes made to the input's value using something like onChange() and setting it to a function that sets the state thus calling render function with an updated value. The problem is that this only works if user enters the value and when it's being altered by the slider it does not call onChange() or any other function I tried. Here's my code:
Function that's supposed to be triggered:
onValueChange: function () {
this.setState({
setTemp: this.refs.location.value
});
},
Inside render function:
var {setTemp} = this.state;
<div className="controlPanel">
<div className="slider vertical" data-slider data-initial-start={curTemp} data-step="5" data-end="110" data-vertical="true">
<span className="slider-handle" data-slider-handle role="slider" tabIndex="1" onClick={this.onValueChange}></span>
<span className="slider-fill" data-slider-fill></span>
<input id="tempInput" type="hidden" ref="location" onChange={this.onValueChange}/>
</div>
</div>
<div className="currentStats">
Temp: {setTemp}
</div>
I tried adding onClick, onMove functions on the slider itself and it does work but I want the function to be called only when the slider's value is changed
Any ideas?