Add documentation for the ajax_template attribute

pull/5195/head
Kalob Taulien 2019-03-22 11:17:37 -06:00 zatwierdzone przez Matt Westcott
rodzic fa5c69ee00
commit 062ff73665
2 zmienionych plików z 15 dodań i 0 usunięć

Wyświetl plik

@ -17,6 +17,7 @@ Core team
* Codie Roelf (Praekelt)
* Lisa Adams (Praekelt)
* Naomi Morduch Toubman
* Kalob Taulien
Contributors
============

Wyświetl plik

@ -324,6 +324,20 @@ The template can be changed on a per-instance basis by defining a ``get_template
In this example, pages that have the ``use_other_template`` boolean field set will use the ``blog/other_blog_page.html`` template. All other pages will use the default ``blog/blog_page.html``.
Ajax Templates
~~~~~~~~~~~~~~
If you want to add AJAX functionality to a page, such as a paginated listing that updates in-place on the page rather than triggering a full page reload, you can set the ``ajax_template`` attribute to specify an alternative template to be used when the page is requested via an AJAX call (as indicated by the ``X-Requested-With: XMLHttpRequest`` HTTP header):
.. code-block:: python
class BlogPage(Page):
...
ajax_template = 'other_template_fragment.html'
template = 'other_template.html'
More control over page rendering
--------------------------------