Materialize: DatePicker in Modal

Created on 1 May 2018  路  2Comments  路  Source: Dogfalo/materialize

When I do

$('#date').datepicker({
    container: 'body'
})

I'm having an error in the console:

Uncaught RangeError: Maximum call stack size exceeded.
at Modal._handleFocus (materialize.js?body=1:3004)

If you select several times, then this happens endlessly

What to do?

Example (Be careful, get ready to close the window, fills up memory)

https://codepen.io/anon/pen/RyVrRK

Most helpful comment

All 2 comments

Using this code will get it working: ( I will work on why container: 'body' causes a bug later)
$(document).ready(function(){
$('.modal').modal();
$('.datepicker').datepicker({
})
});

However, the datepicker is too small to interact with. The datepicker itself is a modal. So basically the modal opens another modal. The datepicker fills the container it is in, in this case the modal. So it will appear small.

By default the datepicker will be placed before the input. If you do not pick container. I think you picked container body to make it fill the screen. However, after a little investigation the modal has a has focus event issue.

Do you need the datepicker in a modal? I will try to investigate more and help.
There only seems to be hacker type things you can do for the moment.
https://codepen.io/anon/pen/wjdbBY

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hartwork picture hartwork  路  3Comments

bradley-varol picture bradley-varol  路  3Comments

alexknipfer picture alexknipfer  路  3Comments

lpgeiger picture lpgeiger  路  3Comments

heshamelmasry77 picture heshamelmasry77  路  3Comments