I have a page that lists all entries from the section 'work'. I would like the user to be able to filter these entries by category but via ajax so I don't have to go to a new page.
{% set entries = craft.entries.section('work').limit(null).search('categories:hotel') %}
This works but each category has to have its own page. Is it possibly to load the filtered entries by ajax? Something using {% if craft.request.isAjax %}? Here is the relevant html:
<div class="filters">
<p class="categories">Categories</p>
<p><a href="{{ url('work') }}">All</a></p>
<p><a href="{{ url('work/hotel') }}">Hotel</a></p>
<p><a href="{{ url('work/bar') }}">Bar</a></p>
<p><a href="{{ url('work/club') }}">Club</a></p>
<p><a href="{{ url('work/restaurant') }}">Restaurant</a></p>
<p><a href="{{ url('work/retail') }}">Retail</a></p>
</div>
{% set entries = craft.entries.section('work').limit(null) %}
<div class="projects">
<ul>
{% for entry in entries %}
<li class="project">
<a href="{{ entry.url }}">
{% for asset in entry.mainPhoto %}
<div class="unveil-wrapper">
<img class="unveil" src="{{ url('assets/images/placeholder.png') }}" alt="{{ entry.title }}">
</div>
{% endfor %}
<p class="name">{{ entry.title }}</p>
<p class="address">{{ entry.address }}</p>
</a>
</li>
{% endfor %}
</ul>
</div>
</section>