Sha256: da5b04419be59c51c0d351ee1365922e43ebaeaec2b6db09558716303baa9227

Contents?: true

Size: 739 Bytes

Versions: 30

Compression:

Stored size: 739 Bytes

Contents

import { Controller } from "@hotwired/stimulus"
import { FetchRequest } from '@rails/request.js'

/*
  attach to a form element to have it submit to a turbo-stream endpoint

  <form action="/contacts" data-controller="refine--turbo-stream-form" data-action="submit->refine--turbo-stream-form#submit">

  Turbo is supposed to handle this natively but we're seeing issues when the form is inside an iframe
*/
export default class extends Controller {
  async submit(event) {
    event.preventDefault()
    const request = new FetchRequest(
      (this.element.method || "POST"),
      this.element.action,
      {
        responseKind: "turbo-stream",
        body: new FormData(this.element)
      }
    )
    await request.perform()
  }
}

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
refine-rails-2.9.9 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.9.8 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.9.7 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.9.6 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.9.5 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.9.4 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.9.3 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.9.2 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.9.1 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.9.0 app/javascript/controllers/refine/turbo-stream-form-controller.js