got flagging to work

This commit is contained in:
Kevin Chugh
2012-12-03 00:09:57 -05:00
parent 033ed6ce92
commit af04f5a31b
2 changed files with 14 additions and 4 deletions

View File

@@ -117,11 +117,13 @@ if Backbone?
@trigger "change", @
flagAbuse: ->
@get("abuse_flaggers").push window.user.get('id')
temp_array = @get("abuse_flaggers")
temp_array.push(window.user.get('id'))
@set("abuse_flaggers",temp_array)
@trigger "change", @
unflagAbuse: ->
@get("abuse_flaggers").pop window.user.get('id')
@get("abuse_flaggers").pop(window.user.get('id'))
@trigger "change", @
display_body: ->

View File

@@ -110,7 +110,13 @@ if Backbone?
type: "POST"
success: (response, textStatus) =>
if textStatus == 'success'
@model.set(response, {silent: true})
###
note, we have to clone the array in order to trigger a change event
that's 5 hours of my life i'll never get back.
###
temp_array = _.clone(@model.get('abuse_flaggers'));
temp_array.push(window.user.id)
@model.set('abuse_flaggers', temp_array)
unvote: ->
window.user.unvote(@model)
@@ -131,7 +137,9 @@ if Backbone?
type: "POST"
success: (response, textStatus) =>
if textStatus == 'success'
@model.set(response, {silent: true})
temp_array = _.clone(@model.get('abuse_flaggers'));
temp_array.pop(window.user.id)
@model.set('abuse_flaggers', temp_array)
edit: (event) ->
@trigger "thread:edit", event