提问人:Gibson 提问时间:9/13/2023 更新时间:9/13/2023 访问量:44
从 Turbo Frame 外部访问目标
Accessing target from outside Turbo Frame
问:
嗨,我有这个模态,里面有一个按钮:
<%= 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 %>
该按钮将调用将调用 recipientRowTarget
的激励控制器
由于该目标在模态之外(在 Turbo 框架之外),它会给我这个错误:
Error: Missing target element "recipientRow" for "recipients" controller
¿如何访问 Turbo 模态之外的目标?如果我将目标放在模态中,它可以正常工作。
多谢
我的控制器:
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
}
答: 暂无答案
评论