admin管理员组文章数量:1023803
I have the following code (i am using the following bootstrap datepicker : /)
The datepicker must be closed when you click on a day. (not the changedate event because a moth of year can also be changed)
everything works fine for just one time. The function is just firing once.
Also I want to retrieve the date from the datepicker
How can you achieve this
(function () {
var setDate = $('_Date').val();
//$('#_datepicker').datepicker('setValue', now);
$('#_datepicker').datepicker('setValue', setDate);
$('#_Date').change(function () {
setDate = $('#_Date').val();
$('#_datepicker').datepicker('setValue', setDate);
console.log('day2');
});
})(jQuery)
$(function () {
$('.datepicker-days td.day').click(function (e) {
e.preventDefault();
console.log('day');
//$('#_datepicker').datepicker('hide');
//alert($('#_datepicker').getDate());
//return false;
});
});
HTML / ASPX:
<div class="col-sm-2" runat="server" id="block_date">
<div class="input-group input-append date" id="datepicker_addcase" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
<asp:TextBox runat="server" ID="cn_Date" CssClass="form-control" type="date-local" placeholder="Date" Text="Date"></asp:TextBox>
<div class="input-group-addon">
<span class="glyphicon glyphicon-calendar add-on"></span>
</div>
</div>
</div>
I have the following code (i am using the following bootstrap datepicker : http://www.eyecon.ro/bootstrap-datepicker/)
The datepicker must be closed when you click on a day. (not the changedate event because a moth of year can also be changed)
everything works fine for just one time. The function is just firing once.
Also I want to retrieve the date from the datepicker
How can you achieve this
(function () {
var setDate = $('_Date').val();
//$('#_datepicker').datepicker('setValue', now);
$('#_datepicker').datepicker('setValue', setDate);
$('#_Date').change(function () {
setDate = $('#_Date').val();
$('#_datepicker').datepicker('setValue', setDate);
console.log('day2');
});
})(jQuery)
$(function () {
$('.datepicker-days td.day').click(function (e) {
e.preventDefault();
console.log('day');
//$('#_datepicker').datepicker('hide');
//alert($('#_datepicker').getDate());
//return false;
});
});
HTML / ASPX:
<div class="col-sm-2" runat="server" id="block_date">
<div class="input-group input-append date" id="datepicker_addcase" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
<asp:TextBox runat="server" ID="cn_Date" CssClass="form-control" type="date-local" placeholder="Date" Text="Date"></asp:TextBox>
<div class="input-group-addon">
<span class="glyphicon glyphicon-calendar add-on"></span>
</div>
</div>
</div>
Share
Improve this question
asked Jan 22, 2015 at 10:25
kishen Biekhramkishen Biekhram
631 silver badge6 bronze badges
2 Answers
Reset to default 3 $('.datepicker-days').on('click', 'td.day', function (e) {
e.preventDefault();
$('#datepicker_addcase').datepicker('hide');
return false;
});
remove first b.stopPropagation() in "bootstrap-datepicker,min.js" and try:
$(document).on('click','td.day:not(\'.disabled\'):not(\'.active\')',function(e){
// MY LOGIC
});
I have the following code (i am using the following bootstrap datepicker : /)
The datepicker must be closed when you click on a day. (not the changedate event because a moth of year can also be changed)
everything works fine for just one time. The function is just firing once.
Also I want to retrieve the date from the datepicker
How can you achieve this
(function () {
var setDate = $('_Date').val();
//$('#_datepicker').datepicker('setValue', now);
$('#_datepicker').datepicker('setValue', setDate);
$('#_Date').change(function () {
setDate = $('#_Date').val();
$('#_datepicker').datepicker('setValue', setDate);
console.log('day2');
});
})(jQuery)
$(function () {
$('.datepicker-days td.day').click(function (e) {
e.preventDefault();
console.log('day');
//$('#_datepicker').datepicker('hide');
//alert($('#_datepicker').getDate());
//return false;
});
});
HTML / ASPX:
<div class="col-sm-2" runat="server" id="block_date">
<div class="input-group input-append date" id="datepicker_addcase" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
<asp:TextBox runat="server" ID="cn_Date" CssClass="form-control" type="date-local" placeholder="Date" Text="Date"></asp:TextBox>
<div class="input-group-addon">
<span class="glyphicon glyphicon-calendar add-on"></span>
</div>
</div>
</div>
I have the following code (i am using the following bootstrap datepicker : http://www.eyecon.ro/bootstrap-datepicker/)
The datepicker must be closed when you click on a day. (not the changedate event because a moth of year can also be changed)
everything works fine for just one time. The function is just firing once.
Also I want to retrieve the date from the datepicker
How can you achieve this
(function () {
var setDate = $('_Date').val();
//$('#_datepicker').datepicker('setValue', now);
$('#_datepicker').datepicker('setValue', setDate);
$('#_Date').change(function () {
setDate = $('#_Date').val();
$('#_datepicker').datepicker('setValue', setDate);
console.log('day2');
});
})(jQuery)
$(function () {
$('.datepicker-days td.day').click(function (e) {
e.preventDefault();
console.log('day');
//$('#_datepicker').datepicker('hide');
//alert($('#_datepicker').getDate());
//return false;
});
});
HTML / ASPX:
<div class="col-sm-2" runat="server" id="block_date">
<div class="input-group input-append date" id="datepicker_addcase" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
<asp:TextBox runat="server" ID="cn_Date" CssClass="form-control" type="date-local" placeholder="Date" Text="Date"></asp:TextBox>
<div class="input-group-addon">
<span class="glyphicon glyphicon-calendar add-on"></span>
</div>
</div>
</div>
Share
Improve this question
asked Jan 22, 2015 at 10:25
kishen Biekhramkishen Biekhram
631 silver badge6 bronze badges
2 Answers
Reset to default 3 $('.datepicker-days').on('click', 'td.day', function (e) {
e.preventDefault();
$('#datepicker_addcase').datepicker('hide');
return false;
});
remove first b.stopPropagation() in "bootstrap-datepicker,min.js" and try:
$(document).on('click','td.day:not(\'.disabled\'):not(\'.active\')',function(e){
// MY LOGIC
});
本文标签: javascriptjquery bootstrap datepicker click event just firing onceStack Overflow
版权声明:本文标题:javascript - jquery bootstrap datepicker click event just firing once - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745583494a2157447.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论