   else
     alert("File could not be uploaded")
 
-publishEvent = (name, detail) ->
-  ev = document.createEvent "CustomEvent"
-  ev.initCustomEvent name, true, false, detail
-  document.dispatchEvent ev
+publishEvent = (target, name, detail) ->
+  $(target).trigger( name, detail )
 
 saveUrl = (container, uuid, filename, contentType, publicUrl, progressColumn, fileColumn) ->
   privateUrl = null

        virtualAttr = "#{container.data('parentType')}[new_#{container.data('association')}_uuids]"
        hiddenField = "<input type='hidden' name='#{virtualAttr}[]' value='#{uuid}' />"
        container.append(hiddenField)
    error: (xhr) ->
      console.log xhr.responseText


      public_url: publicUrl
    success: (data, status, xhr) ->
      privateUrl = data.private_url
      if privateUrl == null
        displayFailedUpload(progressColumn)
      else
