-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Impossible to use after $datepickersContainer is removed from the DOM #516
Comments
@mholt hi, interesting case) I will figure something out. |
Added extra check if container still exists on init, should do the trick |
@t1m0n Oh awesome!! I will try it as soon as I can, thank you! PS. Air Datepicker has been amazing to work with otherwise. It has just about everything I was looking for and will be very suitable for my rather advanced use case :) (I'm building a timeline project, so lots of dates and times.) Thank you for building/maintaining it! |
Finally had a chance to test this. It seems to work for me! Thank you very very much! 💯 |
@mholt Oh great! Glad to hear that it worked for you. |
I have an SPA where the
<body>
is replaced on page transitions, and a new date picker needs to be created. Unfortunately this makes it impossible to use AirDatepicker after a page with an AirDatepicker is replaced with a new page that also has an AirDatepicker, because the lib only allows creating a container element once:air-datepicker/src/datepicker.js
Lines 37 to 44 in 76235dc
This results in an error when clicking the input to open the date picker, because
this.$datepicker.offsetParent
from this line:air-datepicker/src/datepicker.js
Line 710 in 76235dc
is null, so it goes boom 💥 on this line:
air-datepicker/src/datepicker.js
Line 742 in 76235dc
I think a more robust approach would be to allow creating the container again if it does not still exist in the DOM.
Edit: I should clarify, this is only an issue when
container
is not specified in the options when constructing a new AirDatepicker. The problem is that I can't pass in a container because at the time of constructing it I do not know where it will go yet.The text was updated successfully, but these errors were encountered: