Capture data from jQuery Mobile GUI / form elements like sliders, or the flip switch/toggle, and store in a var?
- by Carl Foggin
I have this code, which executes without error, it shows "** slider change **" in the debug console every time the slider changes. But I cannot figure out how to capture the value of the slider so I can store it in a var. Can you help, I'm hoping it's a simple thing.
$( '#page4_Options' ).live( 'pageinit', function(event){
var slideTime = userOptions.getSlideTime() / 1000; // userOptions is my Object to get/set params from localStorage.
$("input[id='slider']").val(slideTime).slider("refresh"); // set default slide time when page init's.
console.log("userOptions.getSlideTime()", userOptions.getSlideTime() );
$( "#slider" ).bind( "slidestop", function(event, ui) {
console.log("** slider change **");
// How do I capture the new slider value into a var?
});
});
Here's the HTML with the slider, it's in a tag:
<div data-role="fieldcontain">
<label for="slider">Slide Duration (seconds):</label>
<input type="range" name="slider" id="slider" value="2" min="0" max="60" />
</div>