-
-
Save juggy/58cb3281df91e705a5fd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
tagName: 'th', | |
downArrow: '▼', | |
upArrow: '▲', | |
actions: { | |
sortBy(model, sortProperty, order) { | |
// Remove all selected classes from all the header links | |
this.$().closest('table').find('th>a').removeClass('selected'); | |
// Add the selected class to our link | |
this.$('a.'+order).addClass('selected'); | |
// Run the sort. | |
this.sendAction('action', model, sortProperty, order); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
queryParams: ['deal_ids', 'date_from', 'date_to'], | |
sortedModel: Ember.computed.sort('model', `sortProperties`), | |
sortProperties: null, | |
actions: { | |
sortBy(model, property, order) { | |
console.log(model, property, order); | |
// generate an array with 'property:order' | |
let attrDirection = [`${property}:${order}`]; | |
// Set the model sorting property to the | |
this.set(`sortProperties`, attrDirection); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment