OSDN Git Service

fix filer
[pettanr/pettanr.git] / app / assets / javascripts / locmare / filer / body / file_body.js.coffee
index 5ba9692..7508316 100644 (file)
@@ -3,17 +3,21 @@ class Locmare.FilerModule.BodyModule.FileBody extends Backbone.View
   \r
   initialize: (options) ->\r
     @body = options.body\r
+    @collection = []\r
     _this = this\r
-    @file_items = @collection().fetch({}).done(() -> _this.render())\r
+    c = @filer().collection\r
+    c.fetch().done ->\r
+      _this.filer().items = c.models\r
+      _this.collection = _.map c.models, (item) ->\r
+        c = _this.file_item_class()\r
+        new c({'file_body': _this, 'item': item})\r
+      _this.render()\r
   \r
   render: () ->\r
     _this = this\r
-    _.each @collection().models, (item) ->\r
-      c = _this.file_item_class()\r
-      file_item = new c({'file_body': _this, 'item': item})\r
-      args = {'file_body': _this}\r
-      template = _.template($("#" + file_item.template_name()).html())\r
-      _this.$el.append(template(args))\r
+    this.$el.html('')\r
+    _.each @collection, (file_item) ->\r
+      _this.$el.append(file_item.render().el)\r
     this\r
   \r
   file_item_class: () ->\r
@@ -31,8 +35,8 @@ class Locmare.FilerModule.BodyModule.FileBody extends Backbone.View
   model: () ->\r
     @filer().model\r
   \r
-  collection: () ->\r
-    @filer().collection\r
+  items: () ->\r
+    @filer().items\r
   \r
   template_dir: () ->\r
     @filer().template_dir\r