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

Best/any way to do trigger Flatpickr from another Stimulus controller? #81

Open
k2director opened this issue Aug 1, 2021 · 0 comments

Comments

@k2director
Copy link

First of all, thanks again for Stimulus-Flatpickr, it's been working great for setting due dates on Invoices in my app! I have a Due Date field which displays the due date of that invoice in a plain English format ("August 30, 2021") and when the user clicks on that, they can pick a new due date with the Flatpickr pop-up. Thanks for making that easy.

Now, I wanted to create a Due Date Shortcut drop-down/select menu, with options like "Today", "In Seven Days", "in 14 days", etc., so a user doesn't have to pick a date manually. So I've created a Select UI drop-down element with those items, and a new Stimulus controller that reads the select whenever it occurs, but I'm wondering about the best way to proceed from here. Ultimately, I want to read the Invoice's Issued date (also a Flatpickr field), then add the number of days selected in the shortcut (for example, 14 days) to that Issued date, and then update the Due Date Flatpcikr field to reflect the new due date in plain English ("Sept 14, 2021").

Any general advice on going about that? In some rough experiments, I'm able to put a Stimulus target on my Due Date flatpickr field, and can use my Shortcut Stimulus controller to change the numeric date value of the field (like "2022-01-01"), but I can't figure out how to change the plain English text that appears in the field (like "August 30, 2021"). But that might not still get me where I need to go, because I still need a way, in my shortcut Javascript controller, to add the user's shortcut choice to the Issue date of the invoice, and then insert that new date into the Due Date field ("2022-01-01"), and update its plain English text ("Jan 1, 2022").

Any ideas appreciated, thanks much!

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

No branches or pull requests

1 participant