Skip to main content

Stimulus - flatpickr

Javascript • Asked by kriera

Hi all i've been trying to do one thing without sucess for few days...

i want to select a date on the flatpickr and then based on that date create a table

Date selected Date selected -1day Date selected -2day Date selected -3day Date selected -4day

//controller_calendar.js

import "flatpickr/dist/themes/dark.css";
export default class extends Flatpickr {

static targets = [ "output" ] <-- want to export the selected date on the flatpickr to the view

change(selectedDates, dateStr,instance) {
console.log (dateStr) <-- this prints out the date i select on the console.
this.outputTarget.textContent = dateStr <-- this should send the dateStr to the outputTarget but doesn't work neither here or on the XX
}
XX <-- if i put it here " this.outputTarget.textContent = dateStr" dateStr doesn't have content.
}

Any idea?

thanks all!


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 20,000+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.