-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
Calendar not showing up in a MODAL Form #47
Comments
Hello, if you add the form as a context processor and load it into your base template it will work fine. The modal needs to load the css and js before it renders the form. app_name/context_processors.py
settings.py
base.html |
@jtangir87 Thank you for suggestion, but this still did not work. Form
context_processors.py
Added this to settings |
In your context processor return {‘contact_form’:contact_form} I think you just missed updating that from your copy and paste from my code. You don’t have a quote_form |
@jtangir87 I posted the wrong code, apologies. Edited. By 'still did not work' I meant javascript error is gone, but the field is rendered as a regular text field, calendar widget does not show up. |
@templargin The only other thing I can suggest without seeing all of your code is that make sure you load {{contact_form.media}} in your base.html and again from your modal template |
@jtangir87 I am having the same issue with flatpickr, but I think the root cause of the problem is the same. I do think the problem comes from jquery conflict somehow (there is a modal package with jquery I'm using). I've created a special repo to demonstrate the issue: https://github.com/templargin/datepicker. If you get a chance, I'd really appreciate your comments - been struggling on this fo quite some time! |
@templargin Is there any update to this issue? I am having the same problem. On first load, it does not work. After closing the modal and then reopening, it does work. Then after form modal submission and page reload, it does not work again unless you close and reopen the modal. jquery-3.5.1.min.js:2 Uncaught TypeError: $element.datetimepicker is not a function error thrown in console. |
I have been meaning to write a blog post about how I resolved the issue. Try my Django Bootstrap Datepicker In Modal Tutorial |
@scambrayj Not really. I tried so many different things but stopped looking for a solution for a moment. My problem is that I need to use the django-bootstrap-modal-forms package because many of my code components are tied to it. But because I spent so much time trying to fix this issue I almost thought to drop the package and rewrite all the code :) @jtangir87 Thank you for the write up, nice blog post. I tried to implement your method for my case but it did not work. Because I additionally use modal form package mentioned above, I believe there is interference between context processor and resulting form. When trying to |
@templargin sorry for the troubles. I am also depending on django-bootstrap-modal-forms. I ended up switching calendar functionality to bootstrap-datepicker. https://bootstrap-datepicker.readthedocs.io/en/latest/ About 5 to 10 min I got it working with the modals perfect. No problems since. If there is no other solution for this package, I recommend that one with django-bootstrap-modal-forms. |
@scambrayj Thank you for the tip! I'll try it out. Do you mind if I reach out to you on a side in case I run into any issues (not to pollute this thread)? |
@templargin sure thing |
@templargin had the same error on modal forms but added the the |
@Ishma59 where did you add it? |
-- added to my base.html to be extended in other templates
--In forms.py
Hope this is what you are looking for and It helps. With this structure a calendar is shown on a Modal form and a timepicker too thanks. |
@Ishma59 thank you, that solved it. The placement of |
Happy it worked |
@jtangir87 Thank you for your reply, it is very helpful. |
Thank you very much, it solved same issue for me too and saved my day. :) |
This was exactly the issue with mine -- I needed to include 'form.media' in both the base and the modal forms HTMLs. |
Calendar not showing up in a Modal form for the first time. If I close the modal and open it again, calendar starts working.
Here is an error in console log I get:
The text was updated successfully, but these errors were encountered: