Skip to content

Instantly share code, notes, and snippets.

@shrunyan
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shrunyan/0176f2511d5376b56a9f to your computer and use it in GitHub Desktop.
Save shrunyan/0176f2511d5376b56a9f to your computer and use it in GitHub Desktop.
Parsley code to iterate on a dataset and filter by GET parameters being posted to the file.
// zip-search-form.tpl
<input id="search" />
<ul id="results"></ul>
// zip-search-results.tpl
// template which generates results being returned to AJAX request
// % is the wildcard character in Parsley
{{each events as event WHERE event.zip_code LIKE '{get_var.term}%'}}
<li>
<h2>{{event.title}}</h2>
<img src="{{event.image.getImage(300)}}" alt="{{event.title}}" />
</li>
{{end-each}}
// zip-search.js
// jQuery posts search term to AJAX page which returns results markup
$('#search').on('keyup', function cb() {
$('#results').load('/ajax/zip-search-results.html/?term='+$(this).val());
});
@shrunyan
Copy link
Author

This gist describes the 3 resources necessary to create a search page in Zesty.

  1. Search page which displays results
  2. JavaScript to request results
  3. Results page which returns rendered results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment