question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a way to get the current input in onChange?

See original GitHub issue

I’ve hacked this in:

var picker = flatpickr('....', {
    onChange : function() {
        picker.calendars[0].input.value = 'test';
    }
});

But I’m pretty sure that’ll break. Is there a cleaner/correct way?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
ricksellerscommented, Jul 7, 2016

Exactly what I was looking for. I am loving this plugin. Thanks!

2reactions
chmlncommented, Jul 7, 2016

I’m having the same problem. I have yet to find a full working example of the onChange event in flatpickr. Could someone post one?

http://chmln.github.io/flatpickr/#onchange

I’ve hacked this in:

var picker = flatpickr('....', {
    onChange : function() {
        picker.calendars[0].input.value = 'test';
    }
});

But I’m pretty sure that’ll break. Is there a cleaner/correct way?

To target an onChange of a specific calendar, you need its flatpickr instance. Either you have something like

flatpickr("#check_in_date", {
    onChange: function(dateObj, dateStr) {
        console.info(dateObj);
        console.info(dateStr);
    }
});

Or do something like

var calendars = flatpickr(".flatpickr"); // multiple instances
calendars.byID("myCalendarID").config.onChange = function(dateobj, datestr){
    console.info(dateobj, datestr);
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get the current state when processing the onChange ...
After much torment, I realized that I can do like this const [inputValue, setInputValue] = useState('') useEffect(() ...
Read more >
How to Get the Value of an Input on Change in React
To get the value of an input on change in React, set an onChange event handler on the input, then use the target.value...
Read more >
React onChange Events (With Examples) - Upmostly
The onChange event in React detects when the value of an input element changes. Let's dive into some common examples of how to...
Read more >
How to Get the Current Value from a Lightning-Input-Rich-Text
Is there a way to increase the polling rate of a lightning-input-rich-text field? ... Can I just get its current value without needing...
Read more >
How to Identify Different Inputs with One Onchange Handler
The most common approach is to attach an onChange event to each input field. Whenever the event is triggered, call a separate function...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found