PageRenderTime 39ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 0ms

/public/javascripts/bbclonemail.collection.js

https://bitbucket.org/asheriff/bbclonemail-poc
JavaScript | 33 lines | 14 code | 4 blank | 15 comment | 0 complexity | 1ec60200dfa8312cf4a2e099b4dfea18 MD5 | raw file
  1. // Backbone.BBCloneMail
  2. // A reference application for Backbone.Marionette
  3. //
  4. // Copyright (C)2012 Derick Bailey, Muted Solutions, LLC
  5. // Distributed Under MIT License
  6. //
  7. // Documentation and Full License Available at:
  8. // http://github.com/derickbailey/backbone.bbclonemail
  9. // http://github.com/derickbailey/backbone.marionette
  10. //
  11. // BBCloneMail Models And Collections
  12. // ----------------------------------
  13. // Provide a guaranteed execution of a "reset" event for
  14. // collections so I can find an item in the collection after
  15. // the collection has been loaded.
  16. BBCloneMail.Collection = Backbone.Collection.extend({
  17. constructor: function(){
  18. var args = Array.prototype.slice.call(arguments);
  19. Backbone.Collection.prototype.constructor.apply(this, args);
  20. this.onResetCallbacks = new Backbone.Marionette.Callbacks();
  21. this.on("reset", this.runOnResetCallbacks, this);
  22. },
  23. onReset: function(callback){
  24. this.onResetCallbacks.add(callback);
  25. },
  26. runOnResetCallbacks: function(){
  27. this.onResetCallbacks.run(this, this);
  28. }
  29. });