Sorry if I'm missing something obvious, but I'm trying to do the following:
post a form's contents to a rails controller
controller does its work and returns turbo-streams
have the page update the frames automatically
Right now, I can submit the data fine, see the controller working fine and it sends the two turbo-streams back to the browser, but request.js is not updating the frames. I do have window.Turbo defined.
Here's my stimulus controller where the call is made:
import { Controller } from "@hotwired/stimulus"
import { Turbo } from '@hotwired/turbo-rails'
import { post } from '@rails/request.js'
export default class extends Controller {
static targets = [ 'form' ]
async submit() {
// Collect up the form field values
let dd = this.formTarget.querySelectorAll('input,select')
let data = {}
dd.forEach((d) => {
data[d.getAttribute('name')] = d.value
})
const url = this.formTarget.getAttribute('action')
const response = await post(url, { responseKind: "turbo-stream", body: JSON.stringify(data) })
if (response.ok) console.log("ok")
}
}
I've tried adding the responseKind and not adding it. I've also tried returning just one frame in my stream. It looks like everything is getting to the server and back, so I'm wondering if I'm not doing something I need to do on the return.
And I just tested it with the latest turbo-rails (0.8.1) but I had tested it previous with 0.7.10. On the stimulus side, I'm using stimulus-rails 0.6.0, but also tested with 0.4.2. Finally, I am using the latest request.js from August 10th, per skypack here.
Am I doing this wrong, or am I expecting it to do something it doesn't do? Thanks!
Sorry if I'm missing something obvious, but I'm trying to do the following:
Right now, I can submit the data fine, see the controller working fine and it sends the two turbo-streams back to the browser, but request.js is not updating the frames. I do have window.Turbo defined.
Here's my stimulus controller where the call is made:
And here's the relevant controller action:
I've tried adding the responseKind and not adding it. I've also tried returning just one frame in my stream. It looks like everything is getting to the server and back, so I'm wondering if I'm not doing something I need to do on the return.
And I just tested it with the latest turbo-rails (0.8.1) but I had tested it previous with 0.7.10. On the stimulus side, I'm using stimulus-rails 0.6.0, but also tested with 0.4.2. Finally, I am using the latest request.js from August 10th, per skypack here.
Am I doing this wrong, or am I expecting it to do something it doesn't do? Thanks!