i'm trying jquery UI slider for edit form in my app rails. When editing object, value of object not passing to position handle look this screenshoot : http://i.cubeupload.com/UlmeEe.png and when i slide handle, value not passing into field. look this screenshoot : http://i.cubeupload.com/5UmYyz.png
in javascript, i set min : 2000 and value get from value of storage.
<script>
$( "#slider" ).slider({
value: $('storage').val(),
animate: true,
range: "min",
min: 2000,
max: 5000,
step: 1000,
change: function(event, ui) {
$('storage').val(ui.value);
}
});
</script>
in edit.html.erb
<div class="field">
<%= f.label :storage, "Storage" %><br/>
<div id="slider"></div> <br/>
<%= f.text_field :storage %>
</div>
how to fix this problem?
Solved..
change javascript with
<script>
$( "#slider" ).slider({
value: $('input#account_storage').val(),
animate: true,
range: "min",
min: 2000,
max: 5000,
step: 1000,
slide: function( event, ui ) {
$( "input#account_storage" ).html( ui.value );
},
change: function(event, ui) {
$('input#account_storage').attr('value', ui.value);
}
});
</script>