/example/02.Exploring_Advanced_Features/01.Augment.html

https://github.com/tbranyen/backbone.layoutmanager · HTML · 57 lines · 41 code · 11 blank · 5 comment · 0 complexity · d78cc78877c9e11f2ce9c6d2a13051ed MD5 · raw file

  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  6. <title>01.Augment</title>
  7. <link rel="stylesheet" href="../_assets/theme.css">
  8. </head>
  9. <body>
  10. <!-- Layout will be inserted here. -->
  11. <div class="main"></div>
  12. <!-- Content template. -->
  13. <script class="template" type="template" id="content">
  14. This is some content...
  15. </script>
  16. <!-- Dependencies. -->
  17. <script src="../../bower_components/jquery/dist/jquery.js"></script>
  18. <script src="../../bower_components/underscore/underscore.js"></script>
  19. <script src="../../bower_components/backbone/backbone.js"></script>
  20. <!-- LayoutManager library. -->
  21. <script src="../../backbone.layoutmanager.js"></script>
  22. <!-- Example code. -->
  23. <script contenteditable="true">
  24. // Setting this option augments `Backbone.View` to work like `Layout`.
  25. Backbone.Layout.configure({ manage: true });
  26. // Now you can create a nested View that is managed by LayoutManager and
  27. // has all the benefits.
  28. var View = Backbone.View.extend({
  29. template: "#content",
  30. // Override the render method with a custom syntax.
  31. render: function(template, context) {
  32. return template(context);
  33. },
  34. // Once the View has finished render, stick it in the Document.
  35. afterRender: function() {
  36. this.$el.appendTo(".main");
  37. }
  38. });
  39. // Initialize the View.
  40. var view = new View();
  41. // Render it!
  42. view.render();
  43. </script>
  44. <h3><a href="02.Swap_Layout.html">Next example: Swap Layout.</a></h3>
  45. </body>
  46. </html>