Search code examples
htmlmaterializeembedding

Materialize calendar without box


I wish to be able to create a Materialize date picker without having to click on the input-style box. Does anyone know if this is possible or how to do so?

Thanks.


Solution

  • With JavaScript open the date picker window by calling the click method on the input field:

    var datepickers = $('.datepicker').pickadate();
    datepickers[0].click();
    

    The next version of materialize adds an open method for which you use as follows:

    var inputs = document.querySelectorAll('.datepicker');
    var datepickers = M.Datepicker.init(inputs);
    datepickers[0].open();