前提・実現したいこと
rails でアプリ開発中、Bootstrapでdropdownをつけたのだが、ページ遷移後の最初のクリックで、dropdown-itemが表示されない。
二回目のクリックからは正常に動く。
該当のソースコード
ユーザーページのhtmlファイルです。
haml
1 .col-4.text-center.shadow.btn.btn-info.dropdown-toggle#dropdownMenuButton{data: {toggle: "dropdown"}, aria: {haspopup: "true", expanded: "false"}} 2 その他 3 .dropdown-menu.dropdown-menu-right{aria: {labelledby: "dropdownMenuButton"}} 4 - if user_signed_in? && @user.id == current_user.id 5 .text-decoration-none.dropdown-item= link_to "情報編集", edit_user_registration_path(@user) 6 - else 7 .text-decoration-none.dropdown-item= link_to "ダイレクトメッセージ", "#" 8 - if user_signed_in? && @user.id == current_user.id 9 .text-decoration-none.dropdown-item= link_to "ログアウト", destroy_user_session_path, method: :delete 10 - else 11 .text-decoration-none.dropdown-item= link_to "通報する", "#"
application.html.haml ヘッド部分
html
1%head 2 %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/ 3 %title Moyoshi 4 = csrf_meta_tags 5 = csp_meta_tag 6 = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' 7 = stylesheet_link_tag "https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/css/swiper.min.css" 8 = javascript_include_tag "https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/js/swiper.min.js" 9 = javascript_include_tag 'application', 'data-turbolinks-track': 'reload' 10 11 %body 12 以下省略
application.js
Javascript
1// This is a manifest file that'll be compiled into application.js, which will include all the files 2// listed below. 3// 4// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's 5// vendor/assets/javascripts directory can be referenced here using a relative path. 6// 7// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8// compiled file. JavaScript code in this file should be added after the last require_* statement. 9// 10// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 11// about supported directives. 12// 13//= require jquery 14//= require rails-ujs 15//= require popper 16//= require bootstrap-sprockets 17//= require bootstrap 18//= require activestorage 19//= require bootstrap-tagsinput 20 21//= require_tree . 22
試したこと
popper.jsの有無の確認と、読み込む順番の変更をしてみたが、変化なし。
turbolinksは消しています。
補足情報(FW/ツールのバージョンなど)
ruby 2.5.1p57
rails 5.2.4.2
jquery-rails 4.3.5
bootstrap 4.4.1
popper_js 1.16.0
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/04/03 01:58
2020/04/03 02:53
2020/04/03 08:37
2020/04/03 09:36