Przeglądaj źródła

W3.6.1: choose document from a Bootstrap nav dropdown.

Frederic G. MARAND 9 lat temu
rodzic
commit
88e4ef853f
2 zmienionych plików z 23 dodań i 0 usunięć
  1. 12 0
      textcircle.html
  2. 11 0
      textcircle.js

+ 12 - 0
textcircle.html

@@ -32,6 +32,18 @@
             New document
           </a>
         </li>
+        <!-- drop down list -->
+        <li role="presentation" class="dropdown">
+          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
+            Documents <span class="caret"></span>
+          </a>
+          <ul class="dropdown-menu">
+            {{#each documents }}
+            <li><a href="#" class="js-load-doc">{{ title }}</a></li>
+            {{/each}}
+          </ul>
+        </li>
+        <!-- end drop down list -->
       </ul>
 
       <p class="navbar-text navbar-right">

+ 11 - 0
textcircle.js

@@ -53,6 +53,12 @@ if (Meteor.isClient) {
     }
   });
 
+  Template.navbar.helpers({
+    documents: function () {
+      return Documents.find();
+    }
+  });
+
   Template.navbar.events({
     "click .js-add-doc": function (event) {
       event.preventDefault();
@@ -68,6 +74,11 @@ if (Meteor.isClient) {
           }
         });
       }
+    },
+
+    "click .js-load-doc": function (event) {
+      // This contains a complete document.
+      Session.set("docid", this._id);
     }
   });
 } // end isClient...