Ruby on rails rails资源-单击链接时无法正常工作,但在刷新或按地址栏中的enter键时可以正常工作。提供Heroku链接
这是heroku上我的应用程序的链接: 它有一个下拉列表,有4个链接,全部指向主url 如果您先单击“下拉列表”,则下拉列表将打开并显示4个链接。当点击一个链接时,它将进入同一页面(带有路径“/”的主页),然后点击下拉菜单现在不起作用。但是,当我们刷新或按地址栏上的enter键时,它就工作了 解决办法是什么 application.html.erbRuby on rails rails资源-单击链接时无法正常工作,但在刷新或按地址栏中的enter键时可以正常工作。提供Heroku链接,ruby-on-rails,Ruby On Rails,这是heroku上我的应用程序的链接: 它有一个下拉列表,有4个链接,全部指向主url 如果您先单击“下拉列表”,则下拉列表将打开并显示4个链接。当点击一个链接时,它将进入同一页面(带有路径“/”的主页),然后点击下拉菜单现在不起作用。但是,当我们刷新或按地址栏上的enter键时,它就工作了 解决办法是什么 application.html.erb <!DOCTYPE html> <html> <head> <title>Assets te
<!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>
app/assets/stylesheets/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/directory中检查这个问题:由于turbolinks没有触发Document.ready事件,所以出现了相同的问题。您有turbolinks和不正确绑定的js事件来打开下拉列表。检查导轨支架或导轨
/*
* 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
*/