Rather than doing pagination by extracting page numbers from data attributes and feeding them into the search action URL, use LINKS with ACTUAL URLS in them. What a time to be alive!

pull/7389/head
Matt Westcott 2021-07-29 00:33:57 +01:00 zatwierdzone przez Matt Westcott
rodzic b3adae22a2
commit 75c417f3a8
2 zmienionych plików z 12 dodań i 27 usunięć

Wyświetl plik

@ -7,8 +7,7 @@ SNIPPET_CHOOSER_MODAL_ONLOAD_HANDLERS = {
});
$('.pagination a', context).on('click', function() {
var page = this.getAttribute('data-page');
setPage(page);
loadResults(this.href);
return false;
});
}
@ -28,31 +27,13 @@ SNIPPET_CHOOSER_MODAL_ONLOAD_HANDLERS = {
data['locale_filter'] = $('#snippet-chooser-locale', searchForm$).val();
}
request = $.ajax({
url: searchUrl,
data: data,
success: function(data, status) {
request = null;
$('#search-results').html(data);
ajaxifyLinks($('#search-results'));
},
error: function() {
request = null;
}
});
loadResults(searchUrl, data);
return false;
}
function setPage(page) {
var dataObj = {p: page};
if ($('#id_q').length && $('#id_q').val().length) {
dataObj.q = $('#id_q').val();
}
request = $.ajax({
url: searchUrl,
data: dataObj,
function loadResults(url, data) {
var opts = {
url: url,
success: function(data, status) {
request = null;
$('#search-results').html(data);
@ -61,8 +42,11 @@ SNIPPET_CHOOSER_MODAL_ONLOAD_HANDLERS = {
error: function() {
request = null;
}
});
return false;
}
if (data) {
opts.data = data;
}
request = $.ajax(opts);
}
$('form.snippet-search', modal.body).on('submit', search);

Wyświetl plik

@ -28,7 +28,8 @@
</tbody>
</table>
{% include "wagtailadmin/shared/ajax_pagination_nav.html" with items=items %}
{% url 'wagtailsnippets:choose_results' model_opts.app_label model_opts.model_name as pagination_base_url %}
{% include "wagtailadmin/shared/pagination_nav.html" with items=items linkurl=pagination_base_url %}
{% else %}
{% if is_searching %}
<p role="alert">{% blocktrans %}Sorry, no snippets match "<em>{{ query_string }}</em>"{% endblocktrans %}</p>