Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to always fire dp.change event #476

Closed
bradpearson opened this issue Aug 11, 2014 · 6 comments
Closed

Option to always fire dp.change event #476

bradpearson opened this issue Aug 11, 2014 · 6 comments

Comments

@bradpearson
Copy link

In some instances, if the date doesn't change and the dp.change event doesn't fire, there is no way to be notified that the user interacted with the control.

For example, if I am listening to dp.change for setting and clearing an error class on a form and a user sets the datepicker value to something invalid (set the form error class to true), then uses the datepicker to change it back to the original date, the change is never fired and there is no way to clear the error.

Perhaps an option to force the dp.change event to fire even if the actual date doesn't change would be helpful in these situations.

@nikoskalogridis
Copy link
Contributor

This can be resolved as follows:

  • Listen for dp.error and add the error class on the field
  • Listen for dp.change and remove the error class from the field

@bradpearson
Copy link
Author

That's what I am doing, the problem is that the second dp.change never fires.
Here is the scenario:

  1. The user selects a date of 1/1/2015 - dp.change is fired
  2. The user invalidates the date with some non parseable string - dp.error is fired
  3. The user again selects the date of 1/1/2015 - dp.change is not fired because the last good parsed date was the same. Nothing fires and there is no event that I can use to clear the error.

Plunkr: http://plnkr.co/edit/IxFCEcX8OD88BwaAY1Jl?p=preview
Note that I am doing this with the option pickTime:false so its just the date that is being picked.

nikoskalogridis added a commit that referenced this issue Aug 13, 2014
@nikoskalogridis
Copy link
Contributor

ok I see your point. try this plunkr it fetches code from development which works as it should

@bradpearson
Copy link
Author

Looks good. Fires the dp.change event after the error is corrected even if it is the same date as the previous one. Thanks.

@nikoskalogridis
Copy link
Contributor

Let's leave this issue open until it is implemented on v4branch as well

nikoskalogridis added a commit that referenced this issue Aug 13, 2014
@nikoskalogridis
Copy link
Contributor

ok implemented in v4beta as well

@nikoskalogridis nikoskalogridis mentioned this issue Aug 15, 2014
@ghost ghost locked and limited conversation to collaborators Jun 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants