topics.js 621 B

1234567891011121314151617181920212223242526272829
  1. var _ = require('underscore');
  2. var Backbone = require('backbone');
  3. var AppState = require('../app_state');
  4. var Topic = require('../models/topic');
  5. var Topics = Backbone.Collection.extend({
  6. model: Topic,
  7. comparator: 'id',
  8. constructor: function Topics() {
  9. Backbone.Collection.prototype.constructor.apply(this, arguments);
  10. },
  11. url: function() {
  12. return AppState.apiPath('/topics');
  13. },
  14. parse: function(resp) {
  15. var topics = _.map(resp['topics'], function(name) {
  16. return {'name': name};
  17. });
  18. return topics;
  19. }
  20. });
  21. module.exports = Topics;