Accessing target from outside Turbo Frame

155 views Asked by At

Hi there, I have this modal that has a button inside:

    <%= turbo_frame_tag 'select_recipients_modal', id: "select_recipients_modal", data: { controller: "recipients" } do %>
       <button class="btn btn-secondary btn-xs rounded-full" data-action="recipients#selectRecipient"
     <% end %>

That button will call a stimulus controller that will call recipientRowTarget

Since that target is outside the modal (outside the Turbo frame), it will give me this error:

Error: Missing target element "recipientRow" for "recipients" controller

¿How can I access the targets that are outside the Turbo modal? If I put the target inside the modal, it works fine.

Thanks a lot

My controller:

export default class extends Controller {
  static targets = [ 'recipientsTable', 'recipientRow', 'recipientsCount', 'modal' ];

  selectRecipient(event) {
    const button = event.currentTarget;
  
    const recipientData = {
      recipientId: button.dataset.recipientId
    };

    console.log(this.recipientRowTarget); // THIS IS NOT ACCESING THE TARGET OUTSIDE TURBO FRAME
  }
  
0

There are 0 answers