-
Notifications
You must be signed in to change notification settings - Fork 4
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
Submit language form on language link click #71
Conversation
Codecov Report
@@ Coverage Diff @@
## master #71 +/- ##
======================================
Coverage 89.3% 89.3%
======================================
Files 41 41
Lines 1506 1506
======================================
Hits 1345 1345
Misses 161 161 |
accesspoc/templates/base.html
Outdated
{% get_available_languages as LANGUAGES %} | ||
{% get_language_info_list for LANGUAGES as languages %} | ||
{% for language in languages %} | ||
<a class="dropdown-item" href="javascript:;" onclick="document.langForm.language.value='{{ language.code }}'; document.langForm.submit();">{{ language.name_local|capfirst }} ({{ language.code }})</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You came this far without a single .js file but perhaps you should have one now to avoid mixing code and markup. It used to be a bad practice IIRC.
<script type="text/javascript" src="{% static 'js/jquery-3.2.1.min.js' %}"></script> | ||
<script type="text/javascript" src="{% static 'js/popper.min.js' %}"></script> | ||
<script type="text/javascript" src="{% static 'js/bootstrap.min.js' %}"></script> | ||
<script type="text/javascript" src="{% static 'js/custom.js' %}"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW HTML 5's type defaults to text/javascript
. It's fine to be explicit but just for your information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done!
To avoid having a submit button inside the language drop-down to send the language change request, create a hidden field inside the form for the language and remove the current check-boxes. Add drop-down links outside the form and change the language input value on link click and submit the form. Squashed commit of the following: commit 6a84f23 Author: José Raddaoui Marín <raddaouimarin@gmail.com> Date: Thu Jul 26 20:23:17 2018 +0200 Move form modification and submission to JS file commit 3103c50 Author: José Raddaoui Marín <raddaouimarin@gmail.com> Date: Thu Jul 26 16:35:30 2018 +0200 Submit language form on language link click To avoid having a submit button inside the language drop-down to send the language change request, create a hidden field inside the form for the language and remove the current check-boxes. Add drop-down links outside the form and change the language input value on link click and submit the form. Include the JS code used for this behavior in the link attributes to avoid loading an entire custom JS only for this.
6a84f23
to
333f012
Compare
To avoid having a submit button inside the language drop-down to send
the language change request, create a hidden field inside the form for
the language and remove the current check-boxes. Add drop-down links
outside the form and change the language input value on link click and
submit the form.
Connects to #16.