Created
March 11, 2019 19:44
-
-
Save webzorg/00b48161a32c77e84973a8aa1260449b to your computer and use it in GitHub Desktop.
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 = ["name", "description", "category", "list"] | |
postSuccess(event) { | |
// console.log("ajax: success"); | |
let [data, status, xhr] = event.detail; | |
this.listTarget.insertAdjacentHTML("afterbegin", xhr.response); | |
this.nameTarget.value = ""; | |
this.descriptionTarget.value = ""; | |
this.categoryTarget.value = ""; | |
} | |
postError(event) { | |
// console.log("ajax: error"); | |
let [data, status, xhr] = event.detail; | |
data.forEach(function(error_message) { | |
alertify.error(error_message); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment