I am trying to use jquery so that when a user selects said value the list is sorted by that value, but my Syntax is wrong and whatever I try doesn't work. Please help!
This is my code:
Order by:
<select id="myselect">
<option value="title">Title</option>
<option value="Last Updated">Last Updated</option>
<option value="Themes">Themes</option>
</select>
<script type="text/javascript">
$(document).change(function() {
if ($("#mySelect").val() == "Title") {
var selection = Model.Children.OrderBy("id desc");}
if ($("#mySelect").val() == "Title") {
var selection = Model.Children.OrderBy("lastUpdated");}
});
</script>
This hasn't worked I think because my content is in a table so I'm going to have to use a different approach - using a datatable, but thanks for your help.
Razor and Jquery select
Hi there
This is making me dizzy!
I am trying to use jquery so that when a user selects said value the list is sorted by that value, but my Syntax is wrong and whatever I try doesn't work. Please help!
This is my code:
Thanks in advance Natasha
Hi Natasha,
Maybe you need selector like that :
Thanks,
Alex
Hi Natasha
I would also take a look at your casing of id's and values as this can prevent your JS from running.
e.g.
/B.
This hasn't worked I think because my content is in a table so I'm going to have to use a different approach - using a datatable, but thanks for your help.
is working on a reply...