我在我的ruby on rails项目中有这个代码,但是我注意到,因为我不知道的原因,onSelect事件中的日期选择器会在ruby on rails项目中触发。
<label for="" class="col-sm-4 control-label">Start Period</label>
<div class="col-sm-5">
<%= text_field_tag "start_period", nil,
class: "form-control ",
id: "activity-customer-start-period",
placeholder: ""
%>
</div>
<label for="" class="col-sm-4 control-label">End Period</label>
<div class="col-sm-5">
<%= text_field_tag "end_period", nil,
class: "form-control",
id: "activity-customer-end-period",
placeholder: ""
%>
</div>
我的js文件
$(document).ready(function() {
$('#activity-customer-start-period').datepicker({
format: 'dd M yyyy',
onSelect: function(selected) {
alert(selected);
}
});
$('#activity-customer-end-period').datepicker({
format: 'dd M yyyy',
autoclose: true,
minDate: $('#activity-customer-start-period').val(),
onSelect: function(selected) {
alert(selected);
$("#activity-customer-start-period").datepicker("option","maxDate", selected);
}
});
});
有谁知道为什么datepicker onselect事件不会在rails项目中工作甚至无法正常工作。我包含了这个jsfiddle文件以获得帮助
http://jsfiddle.net/boyfunky/oqxxmrru/
感谢任何帮助