Closed ghost closed 8 years ago
It only seems to happen if autoclose is set to false. Changing autoclose to true fixes the problem. Weird.
I still don't understand why you are suspecting turbolinks.
Surya Avantsa On Aug 24, 2015 7:31 PM, "Patrick Paul-Hus" notifications@github.com wrote:
I have turbolinks enabled (at least for now) and everything works fine from a regular page load, but if I come from another page, the calendar does show up, but when I click outside of the calendar to close it down the value of the field becomes blank again. I don’t know if anyone else is having that issue. I probably should just not use turbolinks, it’s my first time trying it out.
— Reply to this email directly or view it on GitHub https://github.com/Nerian/bootstrap-datepicker-rails/issues/106.
I suspect turbolinks because I only get the problem if I navigated from another page (using turbolinks). If I load the page with the date picker directly (thus this was a normal request, not an xhr), I don’t have the issue.
Have you set up the initializer like this?
$(document).on('page:change', function(){
$('.datepicker').datepicker();
});
No I’m initializing it using the data attributes. Maybe that’s the problem... but the datapicker does show up though, it just doesn’t behave nice when you select a date and then click outside of it.
Eu tenho o mesmo problema. Depois de clicar fora do input o valor do mesmo desaparece. I have the same problem. After clicking outside the input the value of it disappears.
The origin of the problem is multiple calls for the datepicker method in same html element. This was my solution:
$('.datepicker-js').datepicker({ clearBtn: true });
$( ".datepicker-js" ).removeClass( "datepicker-js");
"br is br.. always"
I also encountered this problem. With "turbolinks" enabled and visiting a page from another page in Rails, the datepicker( ) was not appearing. If you refresh, the page the datepicker( ) works. But visiting from another page it didn't work.
I temporarily disabled turbolinks by adding the "data-no-turbolink" attribute to the body tag, like such:
<body data-no-turbolink>
Make sure that you are making the datepicker call inside a page:change
handler.
$(document).on('page:change', function(){
$('.datepicker').datepicker();
});
I have turbolinks enabled (at least for now) and everything works fine from a regular page load, but if I come from another page, the calendar does show up, but when I click outside of the calendar to close it down the value of the field becomes blank again. I don’t know if anyone else is having that issue. I probably should just not use turbolinks, it’s my first time trying it out.