baarkerlounger
3 years ago
5 changed files with 67 additions and 13 deletions
@ -1,7 +1,18 @@ |
|||||||
import { Controller } from "@hotwired/stimulus" |
// Visit The Stimulus Handbook for more details
|
||||||
|
// https://stimulusjs.org/handbook/introduction
|
||||||
|
//
|
||||||
|
// This example controller works with specially annotated HTML like:
|
||||||
|
//
|
||||||
|
// <div data-controller="hello">
|
||||||
|
// <h1 data-target="hello.output"></h1>
|
||||||
|
// </div>
|
||||||
|
|
||||||
|
import { Controller } from "stimulus" |
||||||
|
|
||||||
export default class extends Controller { |
export default class extends Controller { |
||||||
|
static targets = [ "output" ] |
||||||
|
|
||||||
connect() { |
connect() { |
||||||
this.element.textContent = "Hello World!" |
this.outputTarget.textContent = 'Hello, Stimulus!' |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,14 +1,9 @@ |
|||||||
import { Application } from "@hotwired/stimulus" |
// Load all the controllers within this directory and all subdirectories.
|
||||||
|
// Controller files must be named *_controller.js.
|
||||||
|
|
||||||
const application = Application.start() |
import { Application } from "stimulus" |
||||||
|
import { definitionsFromContext } from "stimulus/webpack-helpers" |
||||||
// Configure Stimulus development experience
|
|
||||||
application.warnings = true |
|
||||||
application.debug = false |
|
||||||
window.Stimulus = application |
|
||||||
|
|
||||||
// Import and register all your controllers within this directory and all subdirectories
|
const application = Application.start() |
||||||
// Controller files must be named *_controller.js or *_controller.ts
|
const context = require.context("controllers", true, /_controller\.js$/) |
||||||
import { definitionsFromContext } from "@hotwired/stimulus" |
|
||||||
const context = require.context("controllers", true, /_controller\.(js|ts)$/) |
|
||||||
application.load(definitionsFromContext(context)) |
application.load(definitionsFromContext(context)) |
||||||
|
Loading…
Reference in new issue