All threads / Stimulus - flatpickr

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Stimulus - flatpickr

kriera asked in Javascript

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!

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 37,629+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.