Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

ui datepicker events, on selection of a date #639

Closed
joshuawoodward opened this issue Jul 8, 2013 · 14 comments
Closed

ui datepicker events, on selection of a date #639

joshuawoodward opened this issue Jul 8, 2013 · 14 comments

Comments

@joshuawoodward
Copy link

can we add some functionality to the scope.select, like an attribute date-select="onSelect()"

I would to perform an action when a date is selected

@bekos
Copy link
Contributor

bekos commented Jul 8, 2013

@joshuawoodward There is already an issue that proposes plugging into the ngModel (#612).

For now, I think you can $watch for changes in your date model inside your controller. Does this work for you?

@joshuawoodward
Copy link
Author

I get;
Uncaught Error: 10 $digest() iterations reached. Aborting! ...

I have a calendar that is hidden, user clicks icon to show calendar, when date is selected i want to hide calendar again (I'm using ui.bootstrap.collapse)

@bekos
Copy link
Contributor

bekos commented Jul 8, 2013

Is this your case? http://plnkr.co/edit/xDv2oDLD8mCLZErn34Rc?p=preview

@joshuawoodward
Copy link
Author

Yes, except that your example is working ;)

@bekos
Copy link
Contributor

bekos commented Jul 8, 2013

Something else is causing your error then!
If you provide a plunker maybe we can help :-)

@joshuawoodward
Copy link
Author

http://plnkr.co/edit/T9eISAXlWtT9JdL6KvZp?p=preview

nested collapses? multiple date pickers?

@bekos
Copy link
Contributor

bekos commented Jul 9, 2013

The problem is caused by the nested collapses. If you want, you can replace the Advanced Search collapse with a ng-hide, like this: http://plnkr.co/edit/5syqgua3DWrQ9qCUZJwN?p=preview

Except that you lose your fancy collapse, everything seems to wok without errors.

@bekos
Copy link
Contributor

bekos commented Jul 9, 2013

There is already the #612 to use ngModelController, so I don;t I think we are going to add the onSelect handler atm.

Your errors are caused from nested collapses, so it is better to open a new issue if this still bothers you.
Closing for now, as there is no action to take.

@bekos bekos closed this as completed Jul 9, 2013
@leesei
Copy link

leesei commented Jul 11, 2013

👍 Recommend adding the collapse/hide sample to the demo page.

@getsetbro
Copy link

A problem with this $watch method, for me, is that it fires when the page loads. http://embed.plnkr.co/4MgBJz/preview

@bekos
Copy link
Contributor

bekos commented Sep 24, 2013

@getsetbro You can now use ng-change.

@colltoaction
Copy link

Sorry for reviving this issue, but it would be nice to have this in the docs!

@zachrybaker
Copy link

second the idea of updating the docs.

@mjoyce91
Copy link

mjoyce91 commented Feb 9, 2017

I was hoping for a similar attribute out of the box to run a callback on date change. A simple solution I discovered was the following:

<div uib-datepicker
        ng-model="selected_date"
        ng-change="go(selected_date)">
</div>

Others may require some more complex, but this was enough for me. I prefer this over $watch.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants