admin管理员组文章数量:1023803
I am using Rails 4 and I have the gem bootstrap3-datetimepicker-rails
installed.
It is working fine, but I want to be able to do an onSelect
call like I can with the normal bootstrap-datepicker.
I want to be able to do something like this:
$("#start").datetimepicker({
minDate: new Date()
}).on("change", function(selectedDate) {
$("#end").datetimepicker({ minDate: selectedDate });
});
$("#end").datetimepicker();
but the documentation is very vague and doesn't seem to include anything on this concept. I am still pretty surprised that this feature of validating start and end dates is not a native option in any date or time picker.
How would I realize this?
Note: I am using bootstrap3-datetimepicker, not the regular bootstrap-datepicker and not jquery-datetimepicker.
Side Note: I've always felt that the world's most ideal automatic datepicker validation would look something like this:
$("#start").datepicker({
minDate: new Date(),
endDate: "#end" // Would automatically call $("#end").datepicker and set the minDate to whatever #start's selected date is
});
I am considering creating my own branch to try and implement it because I feel that the concept of start and end dates is monly ignored when datepickers are created but is so frequently needed.
I am using Rails 4 and I have the gem bootstrap3-datetimepicker-rails
installed.
It is working fine, but I want to be able to do an onSelect
call like I can with the normal bootstrap-datepicker.
I want to be able to do something like this:
$("#start").datetimepicker({
minDate: new Date()
}).on("change", function(selectedDate) {
$("#end").datetimepicker({ minDate: selectedDate });
});
$("#end").datetimepicker();
but the documentation is very vague and doesn't seem to include anything on this concept. I am still pretty surprised that this feature of validating start and end dates is not a native option in any date or time picker.
How would I realize this?
Note: I am using bootstrap3-datetimepicker, not the regular bootstrap-datepicker and not jquery-datetimepicker.
Side Note: I've always felt that the world's most ideal automatic datepicker validation would look something like this:
$("#start").datepicker({
minDate: new Date(),
endDate: "#end" // Would automatically call $("#end").datepicker and set the minDate to whatever #start's selected date is
});
I am considering creating my own branch to try and implement it because I feel that the concept of start and end dates is monly ignored when datepickers are created but is so frequently needed.
Share Improve this question asked Jul 9, 2015 at 21:56 Graham S.Graham S. 1,5501 gold badge21 silver badges29 bronze badges2 Answers
Reset to default 3Take a look at the documentation section on linked pickers: https://eonasdan.github.io/bootstrap-datetimepicker/#linked-pickers
In your case you would do:
$("#start").on("dp.change", function (e) {
$('#end').data("DateTimePicker").minDate(e.date);
});
Try this,
$("#start").datetimepicker({
minDate: new Date()
}).on("change.dp", function(selectedDate) {
$("#end").datetimepicker({ minDate: selectedDate });
});
If not, try this,
$("#start").datetimepicker({
minDate: new Date()
}).on("dp.change", function(selectedDate) {
$("#end").datetimepicker({ minDate: selectedDate });
});
Check bootstrap-3-datetimepicker-events-not-firing-up for more info
I am using Rails 4 and I have the gem bootstrap3-datetimepicker-rails
installed.
It is working fine, but I want to be able to do an onSelect
call like I can with the normal bootstrap-datepicker.
I want to be able to do something like this:
$("#start").datetimepicker({
minDate: new Date()
}).on("change", function(selectedDate) {
$("#end").datetimepicker({ minDate: selectedDate });
});
$("#end").datetimepicker();
but the documentation is very vague and doesn't seem to include anything on this concept. I am still pretty surprised that this feature of validating start and end dates is not a native option in any date or time picker.
How would I realize this?
Note: I am using bootstrap3-datetimepicker, not the regular bootstrap-datepicker and not jquery-datetimepicker.
Side Note: I've always felt that the world's most ideal automatic datepicker validation would look something like this:
$("#start").datepicker({
minDate: new Date(),
endDate: "#end" // Would automatically call $("#end").datepicker and set the minDate to whatever #start's selected date is
});
I am considering creating my own branch to try and implement it because I feel that the concept of start and end dates is monly ignored when datepickers are created but is so frequently needed.
I am using Rails 4 and I have the gem bootstrap3-datetimepicker-rails
installed.
It is working fine, but I want to be able to do an onSelect
call like I can with the normal bootstrap-datepicker.
I want to be able to do something like this:
$("#start").datetimepicker({
minDate: new Date()
}).on("change", function(selectedDate) {
$("#end").datetimepicker({ minDate: selectedDate });
});
$("#end").datetimepicker();
but the documentation is very vague and doesn't seem to include anything on this concept. I am still pretty surprised that this feature of validating start and end dates is not a native option in any date or time picker.
How would I realize this?
Note: I am using bootstrap3-datetimepicker, not the regular bootstrap-datepicker and not jquery-datetimepicker.
Side Note: I've always felt that the world's most ideal automatic datepicker validation would look something like this:
$("#start").datepicker({
minDate: new Date(),
endDate: "#end" // Would automatically call $("#end").datepicker and set the minDate to whatever #start's selected date is
});
I am considering creating my own branch to try and implement it because I feel that the concept of start and end dates is monly ignored when datepickers are created but is so frequently needed.
Share Improve this question asked Jul 9, 2015 at 21:56 Graham S.Graham S. 1,5501 gold badge21 silver badges29 bronze badges2 Answers
Reset to default 3Take a look at the documentation section on linked pickers: https://eonasdan.github.io/bootstrap-datetimepicker/#linked-pickers
In your case you would do:
$("#start").on("dp.change", function (e) {
$('#end').data("DateTimePicker").minDate(e.date);
});
Try this,
$("#start").datetimepicker({
minDate: new Date()
}).on("change.dp", function(selectedDate) {
$("#end").datetimepicker({ minDate: selectedDate });
});
If not, try this,
$("#start").datetimepicker({
minDate: new Date()
}).on("dp.change", function(selectedDate) {
$("#end").datetimepicker({ minDate: selectedDate });
});
Check bootstrap-3-datetimepicker-events-not-firing-up for more info
本文标签: javascriptHow to call quotonSelectquot function for bootstrap3datetimepicker jQueryStack Overflow
版权声明:本文标题:javascript - How to call "onSelect" function for bootstrap3-datetimepicker? jQuery - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745603861a2158614.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论