I'm new to Rails so sorry for the extremely basic question. I'm trying to store the value of a jQuery UI Slider in my database when a form is submitted. For other elements such as a text_area this can be done by
<%= f.text_area :my_score %>
or for a date with datepicker (using the jQuery Datepicker Rails plugin): <%= f.datepicker :my_date %>
. However, I am having trouble finding a plugin for the slider and from my research it seems the best way is through the use of hidden_field. However, I don't know the correct notation for taking the value of the slider and correctly passing it to the form. Any help would be greatly appreciated.
<div id="slider"></div>
<input type="hidden" id="hidden"/>
<%= f.hidden_field :my_score, :value => (what goes here?) %>
Javascript for the slider:
<script>
$(function() {
$( "#slider" ).slider({
value:100,
min: 5,
max: 200,
step: 5,
slide: function( event, ui ) {
$( "#amount" ).val( ui.value );
},
change: function(event, ui) {
$('#hidden').attr('value', ui.value);
}
});
$( "#amount" ).val( $( "#slider" ).slider( "value" ) );
});
</script>