[Date Picker] The date picker doesn't return the correct value when submitting the form with 'onChange' callback #417
Labels
lang/javascript
Anything involving JavaScript
type/bug
Any issue which is a bug or PR which fixes a bug
Milestone
Bug Report
I've a form with date picker and I setup to submit the form as soon as the date is picked and send the form data to the server. But, the form always sends the previous selected date.
Testcase
You can test in this fiddle (http://jsfiddle.net/m7wn3xus/3/). The date picker has
onChange
callback, which triggers the submit event of the form. You can see the serialized array of form data below. The form always send the previous value from the date picker.Current Workaround Solution
I've to update the input field value with the selected date before triggering the submit event. You can test in this fiddle (http://jsfiddle.net/yka8fpsr/1/). The form will be sent the correct date to the server.
In my real world project, I'm implementing the search filters with several date fields and send to the server via Ajax request when the fields have changed the values.
The browser native
onChange
event has no effect on the date picker field. Looks like the date picker module unbind the default events. Try this fiddle (http://jsfiddle.net/54gsqa27/). The two text fields listen the change event, but the date picker field doesn't.So, the only way to trigger the change event is using
onChange
callback from the date picker API, which causes the issue.Version
2.7.1
The text was updated successfully, but these errors were encountered: