私はRailsアプリケーションでjQueryを使ってアニメーション化されたレスポンシブなドロップダウンメニューを持っていますが、メニューリンクの1つをたどると開かれた状態になります。私はリンクをたどることができますが、メニューは開いたままです。 application.jsでjQueryのドロップダウンメニューがページの再読み込みで切り替わらない
<header>
<button class="hamburger">☰</button>
</header>
<div class="menu">
<ul>
<% if current_user %>
<li><%= image_tag @user.profile_picture.thumb.url, class: 'profile_thumb' %> <span><%= current_user.email %></span></li>
<% end %>
<li><%= link_to "Home", root_path %></li>
<li><%= link_to "Pledges", pledges_path %></li>
<% if current_user %>
<li><%= link_to "Edit Profile", edit_user_registration_path %></li>
<li><%= link_to "Log out", destroy_user_session_path, method: :delete %></li>
<% else %>
<li><%= link_to "Sign In", new_user_session_path %></li>
<li><%= link_to "Register", new_user_registration_path %></li>
<% end %>
</ul>
</div>
私のjQuery:私のapplication.html.erbで
application.htmlの頭の中でリンクされ
$(document).ready(function() {
$('.menu').hide();
$('.hamburger').on('click', function() {
$('.menu').slideToggle('slow');
});
});
これは、アプリ/資産/ JavaScriptのに位置し、 .erbそのもの:
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
ありがとうございます。
ありがとう、Ropeney。それはうまく固定されています。 –