Skip to content

daterangepicker - shows previous selected ranges as well #2287

Answered by dangrossman
yameen-zargar asked this question in Q&A
Discussion options

You must be logged in to vote

You're creating a form submit handler inside the callback function for the date range changing, so every time a new date range is selected, you attach another form submit handler to the form. If someone selects 3 date ranges, you now have 3 functions that will run when the form gets submitted, not one.

Instead of doing that, update some global start_date/end_date variables that exist outside of the callback function and move your form submit handler outside that function too.

Or, have the callback function populate some hidden inputs in your form, and then just treat them as any other input in your code to handle the form, which doesn't need to be inside the daterangepicker callback.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@yameen-zargar
Comment options

Answer selected by yameen-zargar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants