0
我想用帶有兩個選擇字段的JQuery-UI Slider選擇一些數據。 HTML.erbrails和帶有兩個選擇字段和ajax選擇數據的Jquery-ui.slider
<%= form_tag "/airports/#{@airport.id}/tablo_out/",:remote => 'true', :method => 'get', :id => "timetableaps_search" do %>
<div id="tablo_form">
<%= select_tag "start_time", options_for_select((DateTime.current.beginning_of_day.to_i..(DateTime.current.end_of_day).to_i).step(1.hour).collect {|x| [Time.at(x).to_s(:time), Time.at(x).utc] } ,params[:start_time]), :onchange => "this.form.submit();"%>
<%= select_tag "end_time", options_for_select(((Time.now.beginning_of_day+1.hour).to_i..(Time.now.beginning_of_day+1.day).to_i).step(1.hour).collect {|x| [Time.at(x).to_s(:time), Time.at(x).utc] } ,params[:end_time]), :onchange => "this.form.submit();"%>
</div>
<% end %>
的JavaScript
$(document).ready(function(){
var container = $('#tablo_form');
var max = $('#start_time').val();
var min = $('#end_time').val();
var rangeSlider = $('<div></div>')
.slider({
min: 1,
max: 24,
step: 1,
values: [1, 24],
range: true,
animate: true,
slide: function(e,ui) {
$(this)
.parent()
.find('#start_time')
.val(ui.values[0]);
$(this)
.parent()
.find('#end_time')
.val(ui.values[1]);
},
stop: function(event, ui) {
// $.get("#", { start_time: $("#start_time").val(), end_time: $("#end_time").val()});
alert($("#start_time").val()+" "+$("#end_time").val());
}
})
.before('<h3>Drag the slider to filter by price:</h3>');
$('#tablo_form').after(rangeSlider).hide();
});
爲什麼$( 「#START_TIME」)。VAL()和$( 「#END_TIME」)。VAL()是空的?