Guest User

Untitled

a guest
Jun 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. var DirectionModel = Backbone.Model.extend({
  2. defaults:{
  3. text : ""
  4. }
  5. });
  6.  
  7. var DirectionsCollection = Backbone.Collection.extend({
  8. model : DirectionModel,
  9. initialize : function(){
  10. this.model.on('destroy', this.change, this);
  11. },
  12. })
  13.  
  14. var IngModel = Backbone.Model.extend({
  15. defaults:{
  16. text : ""
  17. }
  18. });
  19. var IngCollection = Backbone.Collection.extend({
  20. model : ingModel,
  21. initialize : function(){
  22. this.model.on('destroy', this.change, this);
  23. },
  24. })
  25.  
  26.  
  27. var RecipeModel = Backbone.Model.extend({
  28. defaults : {
  29. name : '',
  30. desc : '',
  31. ing : new IngCollection(),
  32. directions : new IngCollection(),
  33. },
  34. initialize : function(){
  35. console.log(this);
  36. }
  37.  
  38. });
  39.  
  40. r = RecipeModel({
  41. "id" : 1,
  42. "name" : 'gsr recipe 1',
  43. "desc" : "some recipe",
  44. ing : [{"id" : 1, "text" : "1 tsp salt"}, {"id" : 2, "text"}],
  45. direction : [{"id" : 1, "text" : "Add salt to tast"}, {"id" : 2, "blah blah"}]
  46.  
  47. })
Add Comment
Please, Sign In to add comment