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.12.0 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.11.12 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.11.11 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.11.10 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.11.9 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.11.8 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.11.6 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.11.5 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.11.4 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.11.3 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.11.2 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.11.1 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.11.0 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.10.1 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.10.0 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.9.14 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.9.13 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.9.12 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.9.11 app/javascript/controllers/refine/turbo-stream-form-controller.js
refine-rails-2.9.10 app/javascript/controllers/refine/turbo-stream-form-controller.js