-
Notifications
You must be signed in to change notification settings - Fork 125
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
Do not require users to load JS first #61
Comments
Why do you need this ? |
Your form widget initializes your plugin inline in the DOM, via a snippet like the following
This is an issue as we are loading all JS, including Jquery, at the bottom of the page. With the above alteration, you can allow the form to initialize without requiring Jquery being loaded at the top of the page. |
Same issue here, a fix would be great! |
I'm working to fix this issue! I hope to push the new version for the end of the week. |
Glad to see this has already been brought up, having the same issue! |
Actually, this problem goes a bit deeper than jQuery alone, I also need put this inside the javascript loading in the bottom of the page: {{ form.media.js }} Right now it needs to be declared before the form is printed, or I get the following error:
|
Hi Guys, |
bcec8a2 solves both problems presented in this issue; jQuery as well as the other js for this widget. |
I am unable to test it at this time, we're currently doing QA for an upcoming release which is taking all my time at the moment. |
@savingschampion Kind prod here, I'm just waiting for a new version of this to get one of my branches into testing :-) |
No dice. I get the error that $ is not defined, because Jquery is being loaded at the bottom of the body.
You can't use A bit of a chicken and the egg problem. To solve it you need to use vanilla JS to wait for the $ variable to become defined. You probably want to try something more like the following.
|
I was trying to fix this in here #72. Personally I move all the |
Same issue here. |
Just giving this widget a try and looks awesome so far, thank you! However, it would be really nice to have this fix! |
I would also benefit from this fix (although it has been 10 months since the issue was submitted and I'm starting to lose hope). |
@asaglimbeni I thought it was fixed already... why it wasn't pushed to pypi? |
It still uses jquery in HTML in the form (even upstream from master). So it is not fixed, yep? |
I'm still facing this issue. Any fixes (even temporary) please? |
@joejean get the code from @siolag161 fork: https://github.com/siolag161/django-datetime-widget |
Thanks @rafaelverger |
What you really want is to do all your JS in an external file with the site-specific stuff in That way, the site developer has the option of setting a Content Security Policy which instructs the browser to disallow inline JavaScript entirely to limit the potential for XSS. (jQuery itself requires inline CSS, which can also be a vector in some circumstances). |
@ssokolow the above pull request does exactly that. |
If all you need is a datepicker (without time functionality) I created https://github.com/RDXT/django-bootstrap3-datepicker which uses only data attributes with https://github.com/uxsolutions/bootstrap-datepicker |
Use something like the following to defer execution of your plugin code, until Jquery is available.
The text was updated successfully, but these errors were encountered: