Alcove CMS
Ru

Part III, Interaction

Forms and regions

Post to a live page and swap only the marked element.

form: in an alcove makes it the front of a form. to names the page that receives it, and the posted values work on that page exactly like the query string, so the filters from the previous sections apply.

Mark an element with alcove-form="name" on both pages. The answer to the post is the page the form was sent from, with only that element replaced by the receiving page's version of it.

Here the form posts to this page itself. Search for a word: the list below the form changes, the rest of the page does not.

Live result This page is rendered on request.

  • A Christmas Carol Charles Dickens, 1843
  • Bleak House Charles Dickens, 1853
  • Emma Jane Austen, 1815
  • Ethan Frome Edith Wharton, 1911
  • Frankenstein Mary Shelley, 1818
  • Great Expectations Charles Dickens, 1861
  • Persuasion Jane Austen, 1817
  • Pride and Prejudice Jane Austen, 1813
  • The Age of Innocence Edith Wharton, 1920
  • The Death of Ivan Ilyich Leo Tolstoy, 1886
  • The Last Man Mary Shelley, 1826
  • War and Peace Leo Tolstoy, 1869

No title contains that.

Source the files behind the result above

content/alcoves/demo_booksearch/alcove.yaml

fields:
  - name: q
    type: text
form:
  to: docs-forms
  fields: [q]

content/alcoves/demo_booksearch/blueprint.html

<form class="finder" action="{{ form.action }}#live" method="{{ form.method }}" role="search">
  {{ form.hidden }}
  <label for="bs-q">Search the titles</label>
  <div class="finder-row">
    <input id="bs-q" name="title-in" type="search" value="{{ query.title-in }}" placeholder="war, house, the">
    <button class="btn btn-dark" type="submit">Search</button>
  </div>
</form>

content/alcoves/demo_bookhits/blueprint.html

<div class="hits" alcove-form="demo_booksearch" data-empty="{{ no_results }}">
  <ul>{{ tiles }}</ul>
  <p class="empty">No title contains that.</p>
</div>