gpt4 book ai didi

ruby-on-rails - rails Assets - 单击链接时无法正常工作,但在地址栏中刷新或按下 Enter 时工作。提供了 Heroku 链接

转载 作者:行者123 更新时间:2023-12-04 06:22:15 26 4
gpt4 key购买 nike

这是我在 heroku 上的应用程序的链接:http://glacial-temple-5892.herokuapp.com/

它有一个包含 4 个链接的下拉菜单,所有链接都指向主页 url。

如果您先单击“下拉列表”,则下拉列表将打开并显示 4 个链接。当一个链接被点击时,它会来到同一个页面(带有路由'/'的主页),然后点击下拉菜单现在不起作用。但是,当我们在地址栏上刷新或按 Enter 键时,它会起作用。

解决办法是什么?

应用程序.html.erb

<!DOCTYPE html>
<html>
<head>
<title>Assets test</title>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<a class="navbar-brand" href="#">Hello </a>
<ul class='nav navbar-nav'>
<li><a >link</a></li>
<li><a >link</a></li>
<li class='dropdown'>
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href='/'>link 1</a></li>
<li><a href='/'>link 2</a></li>
<li><a href='/'>link 3</a></li>
<li><a href='/'>link 4</a></li>
</ul>
</li>
</ul>
</div>
</nav>
<p class='notice'><%= notice %></p>
<p class='alert'><%= alert %></p>
<%= yield %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
</body>
</html>

应用程序/ Assets /javascripts/application.js
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives)        for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//=require dropdown
//= require_tree .

应用程序/ Assets /样式表/application.css
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*=require bootstrap
*/

我将 bootstrap.css 放在供应商/样式表中
我将 dropdown.js 放在 vendor/javascripts/目录中

最佳答案

检查这个 topic :由于 turbolinks 不会触发 Document.ready 事件而导致的相同问题。

关于ruby-on-rails - rails Assets - 单击链接时无法正常工作,但在地址栏中刷新或按下 Enter 时工作。提供了 Heroku 链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18956989/

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