PageRenderTime 37ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/src/gaoqi-py/static/js/model/participatorlist.js

https://bitbucket.org/bobyuxinyang/letsgaoqi
JavaScript | 39 lines | 34 code | 5 blank | 0 comment | 2 complexity | c2f486c6daf7075bf56fd24758a005f8 MD5 | raw file
  1. define(function (require) {
  2. require('model/participator');
  3. var service = require('utility/service');
  4. window.ParticipatorList = Backbone.Collection.extend({
  5. model: Participator,
  6. comparator: function (e) {
  7. return e.get('update_at');
  8. },
  9. idList: [],
  10. initialize: function () {
  11. var _self = this;
  12. _self.idList = [];
  13. var models = _self.models;
  14. for(var key in models){
  15. _self.idList.push(models[key].get('user')['_id']);
  16. }
  17. },
  18. getParticipators: function(){
  19. return this.idList;
  20. },
  21. removeOne: function(index){
  22. var _self = this;
  23. var id = _self.models[index].get('user')['_id'];
  24. _self.idList = _.reject(_self.idList, function(item){
  25. return item == id;
  26. })
  27. },
  28. addOne: function(index){
  29. var _self = this;
  30. var id = _self.models[index].get('user')['_id'];
  31. _self.idList.push(id);
  32. }
  33. });
  34. });