Skip to content

Instantly share code, notes, and snippets.

@dbridges
Last active March 15, 2018 21:25
Show Gist options
  • Save dbridges/f63928f0bac4e4ab2a9a59ea0040488d to your computer and use it in GitHub Desktop.
Save dbridges/f63928f0bac4e4ab2a9a59ea0040488d to your computer and use it in GitHub Desktop.
Rails UJS and Stimulus Comment List
import { Controller } from "stimulus";
export default class extends Controller {
static targets = ["message", "commentList"]
onPostSuccess(event) {
let [data, status, xhr] = event.detail;
this.commentListTarget.innerHTML += xhr.response;
this.messageTarget.value = "";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment