Skip to content

Instantly share code, notes, and snippets.

@mjc
Created May 29, 2014
Embed
What would you like to do?
Sortable example for ember.js
WidgetsController = Ember.ArrayController.extend
sortProperties: ["user.firstName"]
sortAscending: true
actions:
sortBy: (sortProperties) ->
old = @get("sortProperties")
@set "sortProperties", [sortProperties]
@toggleProperty "sortAscending" if sortProperties in old
return false
<table>
<thead>
<th>
Title <button {{action "sortBy" "title"}}>Sort</button>
</th>
</thead>
<tbody>
{{#each}}
<tr>
<td>{{title}}</td>
</tr>
{{/each}}
</tbody>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment