Skip to content

Commit

Permalink
Change school_select_form selects to select2
Browse files Browse the repository at this point in the history
  • Loading branch information
Igifigi committed Sep 2, 2023
1 parent 20c3aec commit 6b360e0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 2 additions & 0 deletions oioioi/base/static/js/select2.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions oioioi/base/static/select2.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 34 additions & 1 deletion oioioi/oi/templates/forms/school_select_form.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
{% load i18n %}
{% load i18n static %}

{% block head %}
<link href="{% static 'base/select2.min.css' %}" rel="stylesheet" />
<script src="{% static 'base/js/select2.min.js' %}"></script>

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/select2.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/select2.min.js"></script>

{% endblock head %}

{% block styles %}
<style>
.select2-container {
width: 100% !important;
}
</style>
{% endblock styles %}


{% for suffix, opts, selected in options %}
<p>
<select name="{{ attr.name }}{{ suffix }}" id="{{ attr.id }}{{ suffix }}">
Expand All @@ -15,3 +34,17 @@
If you can not find your school on the list, please <button type="submit" class="btn btn-xs btn-link" name="_add_school">add it</button>.
{% endblocktrans %}
{% endif %}

{% block script %}
<script>
$(document).ready(function() {
$('#id_school_province').select2();
});
$(document).ready(function() {
$('#id_school_city').select2();
});
$(document).ready(function() {
$('#id_school').select2();
});
</script>
{% endblock script %}

0 comments on commit 6b360e0

Please sign in to comment.