Emit is not triggered on content loaded with ajax

Created on 18 March 2025, about 1 month ago

Problem/Motivation

On my site I am loading a media entity view mode with ajax. My view mode has an emitter in it but it is never triggered.

in the triggers.js file there is a comment // Only run on page load, not for subsequent ajax loads.

It is possible to change this behavior or make it optional?

In my use case I am allowing users to browse media entities in a modal and I want to emit an incident for each one thats viewed not just on full page loads.

Thanks

✨ Feature request
Status

Active

Version

4.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @loze
  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    That comment, and the code implementing that comment, were added by #2651098: Emit javascript being triggered by ajax β†’ to solve a specific problem.

    I have no objections to changing this, if you want to write a patch to do that.

    But it's important to me that we don't regress, so please read that previous issue and propose something that will work in your case without causing the same problem described in that other issue.

  • πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles

    thanks @tr I will check that out and try to write a patch.

    I think it makes sense that if an emitter field is being displayed, then it should emit.

  • Merge request !44allow emitting energy on ajax loaded content β†’ (Open) created by loze
  • Pipeline finished with Success
    about 1 month ago
    #451935
  • πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles

    Here is a MR that achieves what I have proposed, while not effecting what the initial issue was solving.

    Instead of checking for a full page load, I am deleting the emit from drupalSettings once its been used, so subsequent requests will no longer use it. I am only making an ajax request if the emits array is not empty. This allows newly added emits to drupalSettings from ajax loaded content to be triggered

  • Pipeline finished with Success
    about 1 month ago
    Total: 157s
    #451950
Production build 0.71.5 2024