瀏覽代碼

Commit 14-3: Transition between pages by fading.

Frederic G. MARAND 9 年之前
父節點
當前提交
fffbb235a0
共有 2 個文件被更改,包括 15 次插入1 次删除
  1. 13 0
      client/templates/application/layout.js
  2. 2 1
      lib/router.js

+ 13 - 0
client/templates/application/layout.js

@@ -0,0 +1,13 @@
+Template.layout.onRendered(function () {
+  this.find('#main')._uihooks = {
+    insertElement: function (node, next)  {
+      $(node).hide().insertBefore(next).fadeIn();
+    },
+
+    removeElement: function (node) {
+      $(node).fadeOut(function () {
+        this.remove();
+      });
+    }
+  };
+});

+ 2 - 1
lib/router.js

@@ -78,7 +78,8 @@ Router.route('/posts/:_id/edit', {
   },
   },
   data: function () {
   data: function () {
     // "this" is the matched route.
     // "this" is the matched route.
-    return Posts.findOne(this.params._id);
+    var ret = Posts.findOne(this.params._id);
+    return ret;
   }
   }
 });
 });