framework/ember/app/routes/index.js

36 lines
684 B
JavaScript
Raw Normal View History

2014-12-20 14:26:46 +08:00
import Ember from 'ember';
export default Ember.Route.extend({
setupController: function(controller, model) {
controller.set('model', model);
if ( ! model.get('length')) {
controller.set('resultsLoading', true);
2014-12-20 14:26:46 +08:00
controller.getResults().then(function(results) {
controller
.set('resultsLoading', false)
.set('meta', results.get('meta'))
.set('model.content', results);
});
}
},
2015-01-21 11:59:00 +08:00
model: function() {
2014-12-20 14:26:46 +08:00
var model = Ember.ArrayProxy.create();
return Ember.RSVP.resolve(model);
},
actions: {
2015-01-21 11:59:00 +08:00
queryParamsDidChange: function() {
2014-12-20 14:26:46 +08:00
var self = this;
Ember.run.scheduleOnce('afterRender', function() {
self.refresh();
});
}
}
});