Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit 022c16f5874a2760ffc2969552f59caee8aec0db 1 parent 414f981
@shelling authored
View
9 assets/javascripts/application.js
@@ -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) {
View
11 assets/javascripts/views/file.js
@@ -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())
+ );
+ }
+});
View
2  assets/templates/file.js.hamlbars
@@ -1 +1 @@
-%li= "{{ filename }}"
+{{ filename }}
Please sign in to comment.
Something went wrong with that request. Please try again.