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?
render: ->
@template = _.template($("#response-comment-template").html())
params = @model.toJSON()
params['deep'] = @model.has('parent')
if @model.has('parent')
params['parent_id'] = @model.get('parent').id
params['parent_username'] = @model.get('parent').get('username')
params['deep'] = @model.hasOwnProperty('parent')
if @model.hasOwnProperty('parent')
params['parent_id'] = @model.parent.id
params['parent_username'] = @model.parent.get('username')
@$el.html(@template(params))
@initLocal()
@delegateEvents()
......
......@@ -34,7 +34,7 @@ if Backbone?
comments.add(comment)
children = new Comments(comment.get('children'))
children.each (child) ->
child.set('parent', comment)
child.parent = comment
collectComments(child)
@model.get('comments').each collectComments
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