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.

"show" event not working with inline datepicker

See original GitHub issue

I have an inline datepicker and try to alert current selected date (automatically selectedd date). This is my code.

function x(current_date){
        alert(current_date);
}

$('.datepicker').datepicker().on('show', function(e){       
        x(e.format());
 });

but its not alert anything. Please help.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
rav88commented, Sep 16, 2013

First use the .on() method and invoke .datepicker() on the end, so that the behaviour of the show event would be implemented before actually ‘showing’

$('.datepicker').on('show', function(e){       
                x(e.format());
}).datepicker();
0reactions
ancuriskey2000commented, Mar 23, 2022

Hi!

I would like to know how I could use the method “setDatesDisabled()” inside the “on show” event, please. Something like:

$(self.template.querySelector('.datepicker'))
        .on('show', function (e) {
            this.datesDisabled = ['10/04/2022']

        }).on('changeDate', function (selected) {
            let dateval = selected.target.value;
            const selectedEvent = new CustomEvent("datechange", {
                    detail: dateval
                });
            this.dispatchEvent(selectedEvent);
        }).datepicker({
            format: 'dd/mm/yyyy',
            startDate: new Date(),
            endDate: finalDate,
            datesDisabled: disabledDates
        });

I’m doing like that, but I have always been gotten the “Uncaught TypeError: $(…).datepicker is not a function” error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Event not fired on datepicker [duplicate] - Stack Overflow
Closed 4 years ago. I am using bootstrap datepicker inline, when i click on a year , it is fine as i see...
Read more >
inline datepicker beforeShow not occurring - jQuery Forum
The demo shows this in an always open inline datepicker calendar, but I've tried this in a 'regular' datepicker and text box field,...
Read more >
Events — bootstrap-datepicker documentation
Datepicker triggers a number of events in certain circumstances. All events have extra data attached to the event object that is passed to...
Read more >
How to use Bootstrap Datepicker to get date on change event
In this article, we will learn how to use Bootstrap Datepicker to get a date on changes of events. Bootstrap Datepicker is an...
Read more >
Datepicker Widget - jQuery UI API Documentation
For an inline calendar, simply attach the datepicker to a div or span. ... a native change event may not be fired when...
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