Skip to content

Instantly share code, notes, and snippets.

@davidbgk davidbgk/stimulus.html
Last active Mar 27, 2018

Embed
What would you like to do?
Playing with Stimulus tutorial
<!doctype html>
<meta charset=utf-8>
<title>Hello Stimulus</title>
<script src="https://unpkg.com/stimulus/dist/stimulus.umd.js"></script>
<script>
window.addEventListener('DOMContentLoaded', _ => {
const application = Stimulus.Application.start()
application.register('hello', class extends Stimulus.Controller {
static get targets () {
return ['name']
}
greet () {
console.log(`Hello, ${this.name}!`)
}
get name () {
return this.nameTarget.value
}
})
})
</script>
<div data-controller=hello>
<input type=text data-target=hello.name data-action=hello#greet>
<button data-action=hello#greet>Greet</button>
</div>
@davidbgk

This comment has been minimized.

@davidbgk

This comment has been minimized.

Copy link
Owner Author

davidbgk commented Mar 27, 2018

Note that stimulusjs/stimulus#131 has been merged since then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.