Skip to content

Instantly share code, notes, and snippets.

@ryenski
Created January 26, 2018 21:55
Show Gist options
  • Save ryenski/3973b2816fa9a4e54f818219fbc0988c to your computer and use it in GitHub Desktop.
Save ryenski/3973b2816fa9a4e54f818219fbc0988c to your computer and use it in GitHub Desktop.
Clickable table rows with Stimulus.js
<tr data-action="click->table#click" data-controller="table">
<td> 2018-01-11 </td>
<td>
<a data-target="table.url" href="/invoices/1">$7,000.00</a>
</td>
</tr>
import { Controller } from "stimulus"
export default class extends Controller{
click(e){
Turbolinks.visit(this.url)
}
get url() {
return this.targets.find('url').href
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment