mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-27 18:14:48 +00:00
Fixed snippet chooser pagination for non searchable snippets
Pagination links are generated from the search form action. This change always puts the search form into the HTML, but removes the search box and submit button when the snippet is not searchable. The user doesn't see the form and the pagination links work again.
This commit is contained in:
parent
2242244c4b
commit
94565bac8a
2 changed files with 7 additions and 5 deletions
|
|
@ -3,16 +3,18 @@
|
|||
{% include "wagtailadmin/shared/header.html" with title=choose_str subtitle=snippet_type_name icon="snippet" %}
|
||||
|
||||
<div class="nice-padding">
|
||||
{% if is_searchable %}
|
||||
<form class="snippet-search search-bar" action="{% url 'wagtailsnippets:choose' content_type.app_label content_type.model %}" method="GET">
|
||||
{# Need to keep the form in the HTML, even if the snippet is not searchable #}
|
||||
{# This is to allow pagination links to be generated from the form action URL #}
|
||||
<form class="snippet-search search-bar" action="{% url 'wagtailsnippets:choose' content_type.app_label content_type.model %}" method="GET">
|
||||
{% if is_searchable %}
|
||||
<ul class="fields">
|
||||
{% for field in search_form %}
|
||||
{% include "wagtailadmin/shared/field_as_li.html" with field=field %}
|
||||
{% endfor %}
|
||||
<li class="submit"><input type="submit" value="{% trans 'Search' %}" /></li>
|
||||
</ul>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</form>
|
||||
|
||||
<div id="search-results" class="listing snippets">
|
||||
{% include "wagtailsnippets/chooser/results.html" with choosing=1 %}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ function initModal(modal) {
|
|||
function setPage(page) {
|
||||
var dataObj = {p: page, results: 'true'};
|
||||
|
||||
if ($('#id_q').val().length) {
|
||||
if ($('#id_q').length && $('#id_q').val().length) {
|
||||
dataObj.q = $('#id_q').val();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue