Last active
March 15, 2018 21:25
-
-
Save dbridges/f63928f0bac4e4ab2a9a59ea0040488d to your computer and use it in GitHub Desktop.
Rails UJS and Stimulus Comment List
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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