gpt4 book ai didi

javascript - 如何在 Rails 6 中禁用 TurboLinks?

转载 作者:行者123 更新时间:2023-12-03 07:01:44 25 4
gpt4 key购买 nike

所以我遇到了这个问题,我的服务器确实从客户端的请求中检索了正确的数据,并将这些数据发送到浏览器,在那里我可以清楚地看到它对浏览器可用(CTRL+SHIFT+C > Network > my_request)。但是,浏览器不会刷新。所以我现在看到的是前一页的数据。经过一番搜索,我确定它是由 TurboLinks 引起的,然后我尝试将其禁用,如已完成 herehere .然而浏览器仍然不会刷新并显示新获取的数据。我做的最后一件事是grep -r turbolink *在我的项目目录中,它给了我以下信息:

app/views/layouts/_dashboard_menu_certified.html.erb:          <%= submit_tag("Apply", {'data-turbolinks': false}) %>
log/development.log: 21: <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
node_modules/@rails/webpacker/README.md:<%= javascript_packs_with_chunks_tag 'calendar', 'map', 'data-turbolinks-track': 'reload' %>
node_modules/@rails/webpacker/README.md:<script src="/packs/vendor-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
node_modules/@rails/webpacker/README.md:<script src="/packs/calendar~runtime-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
node_modules/@rails/webpacker/README.md:<script src="/packs/calendar-1016838bab065ae1e314.js" data-turbolinks-track="reload"></script>
node_modules/@rails/webpacker/README.md:<script src="/packs/map~runtime-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
node_modules/@rails/webpacker/README.md:<script src="/packs/map-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
node_modules/@rails/webpacker/CHANGELOG.md:<%= stylesheet_packs_with_chunks_tag 'calendar', 'map', 'data-turbolinks-track': 'reload' %>
node_modules/@rails/webpacker/CHANGELOG.md:<%= javascript_packs_with_chunks_tag 'calendar', 'map', 'data-turbolinks-track': 'reload' %>
node_modules/@rails/webpacker/CHANGELOG.md:<script src="/packs/vendor-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
node_modules/@rails/webpacker/CHANGELOG.md:<script src="/packs/calendar~runtime-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
node_modules/@rails/webpacker/CHANGELOG.md:<script src="/packs/calendar-1016838bab065ae1e314.js" data-turbolinks-track="reload"></script>
node_modules/@rails/webpacker/CHANGELOG.md:<script src="/packs/map~runtime-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
node_modules/@rails/webpacker/CHANGELOG.md:<script src="/packs/map-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>

有什么我错过的吗?
干杯。

编辑:
<div class="col-sm-6 card">
<% @res.each do |tool, histories| %>
<div class="chart">
<div class="card-header">
<div class="nav nav-pills card-header-pills">
<%= tool %>
</div>
</div>
<div class="card-body">
<div id="<%= tool %>" class=""></div>
<script>
new Morris.Line({
element: "<%= tool %>",
data: [
<% histories.each do |history| %>
{ date: '<%= history.date %>', value: <%= history.uptodate %>, value2: <%= history.outdated %>, value3: <%= history.error %>},
<% end %>
],
xkey: 'date',
ykeys: ['value', 'value2', 'value3'],
labels: ['UpToDate', 'OutDated', 'Error']
})
</script>
</div>
</div>
<% end %>
</div>

最佳答案

  • 删除 gem 'turbolinks', '~> 5'来自 Gemfile
  • 删除 //= require turbolinks来自 app/assets/javascript/application.js
  • 删除 , 'data-turbolinks-track': 'reload' (x2) 来自 app/views/layouts/application.html.erb
  • 运行yarn remove turbolinks
  • 运行rails tmp:cache:clear

  • 第 4 步是与 Rails 5 的主要区别。

    关于javascript - 如何在 Rails 6 中禁用 TurboLinks?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59305510/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com