Commit a91a5df4 by Ibrahim Awwal

Use regular javascript attributes for parent reference rather than setting

Backbone.Model attributes because Model attributes get serialized into
JSON which is wasteful.
parent f97d4fe9
...@@ -10,10 +10,10 @@ if Backbone? ...@@ -10,10 +10,10 @@ if Backbone?
render: -> render: ->
@template = _.template($("#response-comment-template").html()) @template = _.template($("#response-comment-template").html())
params = @model.toJSON() params = @model.toJSON()
params['deep'] = @model.has('parent') params['deep'] = @model.hasOwnProperty('parent')
if @model.has('parent') if @model.hasOwnProperty('parent')
params['parent_id'] = @model.get('parent').id params['parent_id'] = @model.parent.id
params['parent_username'] = @model.get('parent').get('username') params['parent_username'] = @model.parent.get('username')
@$el.html(@template(params)) @$el.html(@template(params))
@initLocal() @initLocal()
@delegateEvents() @delegateEvents()
......
...@@ -34,7 +34,7 @@ if Backbone? ...@@ -34,7 +34,7 @@ if Backbone?
comments.add(comment) comments.add(comment)
children = new Comments(comment.get('children')) children = new Comments(comment.get('children'))
children.each (child) -> children.each (child) ->
child.set('parent', comment) child.parent = comment
collectComments(child) collectComments(child)
@model.get('comments').each collectComments @model.get('comments').each collectComments
comments.each (comment) => @renderComment(comment, false, null) comments.each (comment) => @renderComment(comment, false, null)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment