Last active
August 29, 2015 14:22
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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()); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist describes the 3 resources necessary to create a search page in Zesty.