Sha256: bd10d3e50c1d094b67326a974b9aabd5f34adf3f5fc22f4dc36b279e7b19c124

Contents?: true

Size: 736 Bytes

Versions: 1

Compression:

Stored size: 736 Bytes

Contents

$(document).ready ->
  # Handles PUT, DELETE, POST methods inside links
  $("a[data-method]").click (event) ->
    event.preventDefault()

    $link = $(event.target)

    createAndSubmitForm = ->
      action = $link.attr("href")
      $form = $("<form />").attr("method", "post").attr("action", action)

      method = $link.data("method")
      $metadataInput = $("<input />").attr("type", "hidden").attr("name", "_method").val(method)

      $form.hide().append($metadataInput).appendTo("body");
      $form.submit()

    confirmationMessage = $link.data("confirm")
    if confirmationMessage?
      bootbox.confirm confirmationMessage, (confirmed) =>
        createAndSubmitForm() if confirmed
    else
      createAndSubmitForm()

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongo_browser-0.1.3 app/assets/javascripts/ujs.js.coffee