Datepicker doesn't open in Angular 1.2.20
Good Afternoon,
I am using 1.2.20, and the date picker dropdown isn't opening when clicking in the text box. This just started happening after I updated to version 0.11
-Jon
They removed this functionality in 0.11. You now have to press the down arrow key to open the datepicker when the text box is focused. I don't think it's very intuitive, but that's the way it is now.
@jbthoma thanks for letting me know. Wow that functionality is messed up. The whole point is to have it open when you click into the box. I wonder if I can find a way to goose it into happening.
@jdscolam Yeah, I've found that appending a calendar button to the input at least keeps users from having to figure out the "down arrow" thing, but I still don't like it.
@jbthoma that was my work-around as well. That being said, I am not going to close this issue as it is an issue. Thanks for your help though! I would have spent hours trying to figure it out.
I'm facing the same issue. Thanks to @jbthoma to explain the reason.
It should be at least an option in my opinion. I can not imagine a datepicker widget without this feature. For now, I'm going to refactor all my date fields in order to use 0.11 version, probably with a ng-focus directive on input field.
@jbthoma can you elaborate on the calendar button or offer up a small code sample of what you're talking about?
@jcarlson assuming you mean calendar (not calculator) button, I just basically do exactly what's on the sample page http://angular-ui.github.io/bootstrap/#/datepicker. Stick a button next to the text box, and make it's ng-click open the calendar pop-up. Alternatively you could also use ng-focus on the text box itself as @Kevlys suggested. This would make it work like it did prior to 0.11.
Coding beyond your bed time leads to typos. Yes, calendar.
I also ran into some issues trying to get a "calendar" button to open the popup. Feeling saucy, I tried to avoid needing a controller method, like mentioned in the sample docs:
<div class="input-group">
<input type="text" class="form-control" ng-model="filter.onOrBefore"
datepicker-popup="yyyy-MM-dd" is-open="onOrBeforeOpened" datepicker-options="{showWeeks: false}" />
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="onOrBeforeOpened = true"><i
class="glyphicon glyphicon-calendar"></i></button>
</span>
</div>
That didn't work, and I spent a while trying to figure out why. It's because of this little glob of code: https://github.com/angular-ui/bootstrap/blob/master/src/datepicker/datepicker.js#L554-L560
Basically, if you click anywhere in the document, and it isn't the field itself, the popup gets closed.
I gave in and added a method on my controller; you have to stop propagation on the click event. That's what threw me off. Not well documented and it seems like there could be a better way to handle that case.
Thank you jcarlson for your post! I too was trying to save code and just set the open variable in the html and couldn't figure out why it wouldn't work - that definitely needs to be documented!
I am closing this issue as we do not support Angular 1.2 anymore (& it is too old).