PageRenderTime 50ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/Backbone/L1/course-hands-on-code/hands-on/02-collection-04.html

https://github.com/csnemeth79/Coursez
HTML | 43 lines | 29 code | 14 blank | 0 comment | 0 complexity | 690a3f9e9085ccc0db9070067180b413 MD5 | raw file
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>Collection 04</title>
  5. <link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" />
  6. <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
  7. <script type="text/javascript" src="http://static.stackmob.com/js/json2-min.js"></script>
  8. <script type="text/javascript" src="http://static.stackmob.com/js/underscore-1.3.3-min.js"></script>
  9. <script type="text/javascript" src="http://static.stackmob.com/js/backbone-0.9.2-min.js"></script>
  10. <script>
  11. (function($){
  12. Wine = Backbone.Model.extend();
  13. Wines = Backbone.Collection.extend({
  14. Model: Wine,
  15. url: "#"
  16. });
  17. wines = new Wines();
  18. wines.on('add remove', function(model, color) {
  19. console.log("you've changed the collection");
  20. });
  21. var firstWine = new Wine({
  22. name: 'Clos Pegase'
  23. });
  24. wines.add(firstWine);
  25. }(jQuery));
  26. </script>
  27. </head>
  28. <body></body>
  29. </html>