Skip to content

Instantly share code, notes, and snippets.

@mjc
Created May 29, 2014 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjc/70f55f44586bf3eb4105 to your computer and use it in GitHub Desktop.
Save mjc/70f55f44586bf3eb4105 to your computer and use it in GitHub Desktop.
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