Reputation: 163
I'm trying to get the value of the range_field_tag
and display it in the page, modifying the number as it moves along. (So it starts at value 1 and displays 1, move the slider up to 3 and the displayed value changes to 3).
<%= range_field_tag 'ranger', in: 1...10, step: 1 %>
Do I have to extract the value of this in the controller or is there a way to get that working in erb? Or will that require Javascript?
Upvotes: 1
Views: 1511
Reputation: 4133
You should be using JavaScript to display
<% # your erb %>
<%= range_field_tag 'ranger', in: 1...10, step: 1 %>
<div id='target'></div>
#JavaScript using JQuery & coffee - works in Chrome
$('#ranger').on 'input', ->
$('#target').text($('#ranger').val())
Upvotes: 2