bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Datepicker doesn't open in Angular 1.2.20

Open jdscolam opened this issue 12 years ago • 10 comments

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

jdscolam avatar Jul 28 '14 17:07 jdscolam

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 avatar Aug 01 '14 20:08 jbthoma

@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 avatar Aug 03 '14 19:08 jdscolam

@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 avatar Aug 04 '14 12:08 jbthoma

@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.

jdscolam avatar Aug 04 '14 14:08 jdscolam

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.

Kevlys avatar Aug 05 '14 14:08 Kevlys

@jbthoma can you elaborate on the calendar button or offer up a small code sample of what you're talking about?

jcarlson avatar Aug 06 '14 03:08 jcarlson

@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.

jbthoma avatar Aug 06 '14 12:08 jbthoma

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.

jcarlson avatar Aug 06 '14 13:08 jcarlson

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!

john-ring avatar Jan 21 '15 16:01 john-ring

I am closing this issue as we do not support Angular 1.2 anymore (& it is too old).

wesleycho avatar Aug 01 '15 18:08 wesleycho