Permalink
Browse files

DropboxIO.View.File is in charge of rendering DropboxIO.Template["file"]

  • Loading branch information...
1 parent 414f981 commit 022c16f5874a2760ffc2969552f59caee8aec0db @shelling committed Dec 5, 2012
Showing with 15 additions and 7 deletions.
  1. +3 −6 assets/javascripts/application.js
  2. +11 −0 assets/javascripts/views/file.js
  3. +1 −1 assets/templates/file.js.hamlbars
@@ -3,6 +3,7 @@
//=require dropboxio
//=require_tree ./models
//=require_tree ./collections
+//=require_tree ./views
//=require_tree ../templates
$(document).ready(function() {
@@ -17,9 +18,7 @@ $(document).ready(function() {
url: "/file",
done: function(e, data) {
new DropboxIO.Collection.Files(data.result).each(function(file) {
- $(".filelist").append(
- DropboxIO.Template["file"](file.toJSON())
- );
+ new DropboxIO.View.File({model: file}).render();
});
$(this).find(".fileupload-progress")
.addClass("fade")
@@ -40,9 +39,7 @@ $(document).ready(function() {
new DropboxIO.Collection.Files().fetch({
success: function(self, response) {
self.each(function(file) {
- $(".filelist").append(
- DropboxIO.Template["file"](file.toJSON())
- );
+ new DropboxIO.View.File({model: file}).render();
});
},
error: function(self, xhr) {
@@ -0,0 +1,11 @@
+DropboxIO.View.File = Backbone.View.extend({
+ initialize: function() {
+ $(".filelist").append(this.$el);
+ },
+ tagName: "li",
+ render: function() {
+ this.$el.html(
+ DropboxIO.Template["file"](this.model.toJSON())
+ );
+ }
+});
@@ -1 +1 @@
-%li= "{{ filename }}"
+{{ filename }}

0 comments on commit 022c16f

Please sign in to comment.