Skip to content

Add the target element to turbo:before-fetch-(request | response) events#367

Merged
dhh merged 1 commit into
hotwired:mainfrom
kapantzak:add-target-to-network-request-related-events
Sep 1, 2021
Merged

Add the target element to turbo:before-fetch-(request | response) events#367
dhh merged 1 commit into
hotwired:mainfrom
kapantzak:add-target-to-network-request-related-events

Conversation

@kapantzak
Copy link
Copy Markdown
Contributor

What

This PR makes turbo:before-fetch-request and turbo:before-fetch-response events to fire on the respective form or frame element.

Why

This way, we can easily attach event listeners to the desired elements, instead of listening for these events on the document.

How

  • By adding the optional target parameter to the FetchRequest's class contructor
  • By passing the FrameElement to the FetchRequest constructor from visit method of FrameController class
  • By passing the form element to the FetchRequest constructor inside FormSubmission's class constructor

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants