```coffeescript
$(document).on 'ajax:success', '[data-replace-self-on-ajax-success]', (event, data, status, xhr) ->
  $(this).replaceWith(data)
  $.fancybox.update()

```

Replace on ajax:sucess triggers replace:success
user
```coffeescript
$(document).on 'ajax:success', '[data-replace-self-on-ajax-success]', (event, data, status, xhr) ->
  newEl = $(data)
  $(this).replaceWith(newEl)
  newEl.trigger('replace:success')
```
assistant