1
0
Fork 0

Hack: admin props combobox works(?)

This commit is contained in:
Dariusz Niemczyk 2023-07-17 22:44:44 +02:00
parent 154e1079da
commit 027bcfcde5
No known key found for this signature in database
1 changed files with 24 additions and 7 deletions

View File

@ -1,10 +1,18 @@
{% extends "admin/change_form.html" %} {% block submit_buttons_top %} {# We want {% extends "admin/change_form.html" %}
add another to be default submit action #}
<input type="submit" value="Save" class="hidden" name="_addanother" /> {% block submit_buttons_top %}
{{ block.super }} {% endblock %} {% block submit_buttons_bottom %} {# We want {# We want add another to be default submit action #}
add another to be default submit action #} <input type="submit" value="Save" class="hidden" name="_addanother" />
<input type="submit" value="Save" class="hidden" name="_addanother" /> {{ block.super }}
{{ block.super }} {% endblock %} {% block content %}{{ block.super }} {% endblock %}
{% block submit_buttons_bottom %}
{# We want add another to be default submit action #}
<input type="submit" value="Save" class="hidden" name="_addanother" />
{{ block.super }}
{% endblock %}
{% block content %}{{ block.super }}
<script> <script>
django.jQuery(function () { django.jQuery(function () {
function fmt(state) { function fmt(state) {
@ -24,6 +32,15 @@ add another to be default submit action #}
django.jQuery(".django-select2[name=parent]").djangoSelect2({ django.jQuery(".django-select2[name=parent]").djangoSelect2({
templateResult: fmt, templateResult: fmt,
}); });
/**
* Extremely ugly hack to make sure autocomplete loads for the props
* There's like 4 select2 versions and jQuery versions.
* I give up trying to make it work in a better way.
* This is good enough.
*/
setTimeout(function () {
django.jQuery(".hstore-toggle-txtarea").click().click();
}, 100);
}); });
</script> </script>
{% endblock %} {% endblock %}