diff options
Diffstat (limited to 'public/assets/js/lib/views/index/hootbox.js')
| -rw-r--r-- | public/assets/js/lib/views/index/hootbox.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/public/assets/js/lib/views/index/hootbox.js b/public/assets/js/lib/views/index/hootbox.js new file mode 100644 index 0000000..43c4fe9 --- /dev/null +++ b/public/assets/js/lib/views/index/hootbox.js @@ -0,0 +1,37 @@ +var HootboxView = FormView.extend({ + + el: "#hootbox", + + events: { + }, + + initialize: function(){ + this.__super__.initialize.call(this) + this.template = this.$(".template").html() + this.$hoots = this.$("#hoots") + }, + + load: function(comments){ + comments.forEach(this.prependComment.bind(this)) + }, + + parse: function(comment){ + var t = this.template.replace(/{{username}}/g, comment.username) + .replace(/{{comment}}/g, comment.comment) + return t + }, + + prependComment: function(comment){ + var $el = $( this.parse(comment) ) + this.$hoots.prepend($el) + }, + + appendComment: function(comment){ + var $el = $( this.parse(comment) ) + this.$hoots.append($el) + }, + + success: function(){ + this.prependComment(comment) + } +})
\ No newline at end of file |
