我正在尝试在我的Rails应用程序中使用turbo_frame_tag来管理一些任务。我为我的任务创建了一个脚手架。
我将要使用的页面包装在以下的turbo frame标记内:
<%= turbo_frame_tag "modal" do %>
<h1>New task</h1>
<%= render "form", task: @task %>
<br>
<div>
<%# <%= link_to "Back to tasks", tasks_path %> %>
<%= link_to "Cancel", "#", data: {
controller: "modals",
action: "modals#close"
}, class: "cancel-button" %>
</div>
<% end %>
在我的主页index.html.erb文件中,我使用相同的标签向我的添加按钮添加了数据:
<%= link_to "Add", new_task_path, data: { turbo_frame: "modal" }, class: "btn btn-secondary", remote: true %>
模态框正常工作。当我在主页上单击“添加”按钮时,它会打开。当我尝试提交我的操作以创建新任务时,在我的终端上看到200响应,并将新任务添加到我的数据库中。
但是(也)我在主页上收到“内容丢失”的文本信息。页面没有重新加载。在开发者浏览器中,我得到了这个错误:
turbo.es2017-esm.js:3650 Uncaught (in promise) Error: The response (200) did not contain the expected \<turbo-frame id="modal"\> and will be ignored. To perform a full page visit instead, set turbo-visit-control to reload.
at c.delegateConstructor.throwFrameMissingError (turbo.es2017-esm.js:3650:15)
at c.delegateConstructor.handleFrameMissingFromResponse (turbo.es2017-esm.js:3646:14)
at c.delegateConstructor.loadFrameResponse (turbo.es2017-esm.js:3567:18)
at async c.delegateConstructor.loadResponse (turbo.es2017-esm.js:3441:34)
我刚开始学习Ruby on Rails,一切都很新鲜。如果有人遇到过这样的问题并知道如何解决,我将不胜感激,希望能得到帮助和信息。