Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action params not populating #117

Closed
cashmann opened this issue Feb 20, 2023 · 1 comment
Closed

Action params not populating #117

cashmann opened this issue Feb 20, 2023 · 1 comment

Comments

@cashmann
Copy link

cashmann commented Feb 20, 2023

I'm having an issue where my Stimulus controller is not picking up event params for a click action. I'm referencing https://stimulus.hotwired.dev/reference/actions#action-parameters to wire this up. Here's a simple setup I have:

View code:

<%= search_form_for @q, url: "#",  html: { data: { controller: "balance form" } } do |f| %>
...
  <tr data-action="click->balance#updateTargetRow" data-balance-id-param="2">
...

Stimulus controller code:

// app/javascript/controllers/balance_controller.js
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {

  updateTargetRow(event) {
    console.log(event.params) //always logs `{}`
    ...
  }
}

Accessing the param via event.currentTarget.dataset.balanceIdParam gives the expected value of "2" in this example. Is this a known issue or do I have something setup wrong?

@cashmann
Copy link
Author

Nevermind, I'm an idiot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant