delete snippets in ajax (wip)

This commit is contained in:
did 2011-12-05 15:19:57 -08:00
parent 5d750bee44
commit dd15e3a758

View File

@ -0,0 +1,33 @@
Locomotive.Views.ThemeAssets ||= {}
class Locomotive.Views.ThemeAssets.IndexView extends Backbone.View
el: '#content'
events:
'click .box a.remove': 'remove_asset'
render: ->
return @
remove_asset: (event) ->
event.stopPropagation() & event.preventDefault()
link = $(event.target)
$.rails.ajax
url: link.attr('href')
type: 'post'
dataType: 'json'
data:
_method: 'delete'
success: @on_successful_delete
error: @on_failed_delete
on_successful_delete: (data, status, xhr) ->
console.log('youpi')
$.growl('success', xhr.getResponseHeader('X-Message'))
on_failed_delete: (data, status, xhr) ->
$.growl('error', xhr.getResponseHeader('X-Message'))