Closed artmem closed 11 years ago
You could do this with javascript:
$(function() {
$("[name=orderby]").on("change", function() {
var sort = ($(this).val() === "date") ? "desc" : "asc";
$("[name=sort]").val(sort);
});
});
Thanks. Where would I put the script? I tried it right below the dynamo tags, but it doesn't do anything:
{exp:dynamo:form return="hr/{segment_2}" search_id="{segment_3}"}
<p class="table-sort">Sort Applicants by:
<select name="orderby" class="two">
<option value="date">Date</option>
<option value="job_reference">Job</option>
</select>
<input class="tiny round button" type="submit" value="Sort" />
</p>
{/exp:dynamo:form}
{exp:dynamo:entries channel="{embed:channel}" dynamic_parameters="orderby" sort="desc" search_id="{segment_3}" limit="25" paginate="bottom" status="open" disable="categories|category_fields|member_data"}
Entry Tags
{/exp:dynamo:entries}
<script>
$(function() {
$("[name=orderby]").on("change", function() {
var sort = ($(this).val() === "date") ? "desc" : "asc";
$("[name=sort]").val(sort);
});
});
</script>
Add a hidden input to your search form:
<input type="hidden" name="sort" value="desc">
Also remove sort param from your dynamo:entries tag, and add sort to your list of dynamic_parameters="orderby|sort"
I'm setting up a page that lists job applicants. I want users to be able to sort the list by date, or by the job applied for, and it's working great. The issue is, when users sort by date, I want the sort to be "desc" and when they search by job, I want the sort to be "asc", but I don't want to have a second sort order drop down, I just want to set both at once with a single drop down (these aren't tech-savvy users, they will be confused by asc vs desc in relation to dates). Is this possible?