-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Prevent unwanted change event when page loads #149
Comments
after some test I noticed this only happens when Pikaday is configured inside of a $() function. |
Great, thanks. |
Is there a way to get around this without having to put the code in the HTML? I'm using Pikaday as part of an Ember component so putting the initializer into the HTML isn't really an option. Are there are pika-specific events I can watch for? |
Any solution to this? |
I was able to fix this without putting the initialization in the HTML by editing the pikaday.js file on line 730 where there's a fireEvent call...I wrapped it with an if statement checking to see if 'preventOnSelect' was true because the initialization case was the only one I could find where true was sent in rather than null/false. Code (with a few surrounding lines for clarity) looks like this:
|
Can you please reopen the issue and fix this? I actually have a case where this behavior causes a stackoverflow as it will call the onchange event over and over again. I don't see why the onchange event should be emitted when nothing actually changed. Thanks a ton! |
Edited setDate to resolve issue Pikaday#149 where Pikaday unintentionally fires a 'change' event on page load, if the input form field associated with the Pikaday component contains a pre-filled value set from prior user input. The fix at lines 852-854 instead have the library temporarily cache the old value before setting the new value, then the old and new are compared before fireEvent() is called to trigger the 'change' event. The library will now only fire the 'change' event if the value has changed. This has been successfully tested to resolve issue 149. Please feel free to accept the PR or adjust as desired.
I had the same issue, and found that even the most recent version of Pikaday fires the I found that by modifying Feel free to merge the changes referenced in the above forked commit to resolve #149. |
I have a form with a pre-populated date input which i'm listen the change event to fetch results via ajax.
Happens every time the page is loaded the date input triggers the change event, which makes an unnecesary ajax request because the page is loading with results already.
Is there any way to avoid or silence the event only when the page just finished to load?
I'm wondering this because the prepopulated value is '21/05/2014' and the value after the change event remains '21/05/2014'
This is the code i'm using to configure Pikaday
The text was updated successfully, but these errors were encountered: