From 96f323a88c145bcd1ccfa38733c2ce93bebb5cf7 Mon Sep 17 00:00:00 2001 From: Ryan W Date: Wed, 11 Jan 2023 22:19:23 -0800 Subject: [PATCH] more stimulus tests --- app/javascript/controllers/hello_controller.js | 11 ++++++++++- app/views/welcome/index.html.erb | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app/javascript/controllers/hello_controller.js b/app/javascript/controllers/hello_controller.js index 5975c07..7571df8 100644 --- a/app/javascript/controllers/hello_controller.js +++ b/app/javascript/controllers/hello_controller.js @@ -1,7 +1,16 @@ import { Controller } from "@hotwired/stimulus" export default class extends Controller { + static targets = [ "name", "output" ] + connect() { - this.element.textContent = "Hello World!" + // this.element.textContent = "Hello World!" + console.log('Hello World hello_controller.js'); + } + + greet() { + console.log('greet'); + this.outputTarget.textContent = + `Hello, ${this.nameTarget.value}!` } } diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 30e0a75..be4bade 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -1,3 +1,17 @@

Welcome

<%= link_to "Articles", articles_path %> + + +

Stimulus Check

+ +
+ + + + + + +