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 passed when event is load@window, working otherwhise? #556

Closed
gremo opened this issue Jul 5, 2022 · 6 comments
Closed

Comments

@gremo
Copy link

gremo commented Jul 5, 2022

Am I'm missing something from the documentation?

<a data-controller="test"
  data-action="load@window->test#foo mouseover->test#foo"
  data-test-bar-param="baz">
  Hello World!
</a>

When load@window event params is an empty object. When mouseover it's ok { bar: "baz" }.

// test_controller.js
import { Controller } from '@hotwired/stimulus';

export default class extends Controller {
  foo({ params }) {
    console.log(params);
  }
}
@rupasix
Copy link

rupasix commented Jul 5, 2022

Probably window load event happened before your controller wiring with HTML.
EDIT: I made wrong assumption that event is not triggered. I was not aware of "params" functionality :) Please ignore this message

@lb-
Copy link
Contributor

lb- commented Jul 5, 2022

If you want to listen to an event as early as possible you can try readystatechange https://developer.mozilla.org/en-US/docs/Web/API/Document/readystatechange_event

@gremo
Copy link
Author

gremo commented Jul 5, 2022

@rupasix

The load event is fired when the whole page has loaded, including all dependent resources such as stylesheets and images.

Exactly what I need/want.

@adrienpoly
Copy link
Member

There is on known issue #495 merge but not yet published.

Will check for what is required to get this released

@gremo
Copy link
Author

gremo commented Jul 5, 2022

@adrienpoly will be released soon? Thanks, closing this

@gremo gremo closed this as completed Jul 5, 2022
@gremo
Copy link
Author

gremo commented Jul 8, 2022

@adrienpoly any update about the new release? We really need this feature!

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

4 participants