amsul / pickadate.js

The mobile-friendly, responsive, and lightweight jQuery date & time input picker.
http://amsul.ca/pickadate.js
MIT License
7.7k stars 1.02k forks source link

Cannot read property 'set' of undefined #1207

Open woeterman94 opened 4 years ago

woeterman94 commented 4 years ago

I'm trying to edit the min value of an existing picker on my page. I'm using

 $('#FromDate').pickadate('picker').set('min', true);
        $('#ToDate').pickadate('picker').set('min',true);

When putting the code in my document.ready I get the following error Cannot read property 'set' of undefined

Placing the code in an $(window).on('load', function ()) works, but then the changes are not always applied to the datepicker Q.Q.

What am I missing here?

DanielRuf commented 4 years ago

Placing the code in an $(window).on('load', function ())

Well, the code and libraries are initialized after documentready so this is expected and normal.

xavierhb commented 4 years ago

So what is the right approach for setting a value once the pickadate has been initialised if not tin the $(document).ready(function() {)); block?