質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

JavaScript

JavaScriptは、プログラミング言語のひとつです。ネットスケープコミュニケーションズで開発されました。 開発当初はLiveScriptと呼ばれていましたが、業務提携していたサン・マイクロシステムズが開発したJavaが脚光を浴びていたことから、JavaScriptと改名されました。 動きのあるWebページを作ることを目的に開発されたもので、主要なWebブラウザのほとんどに搭載されています。

Q&A

0回答

391閲覧

確認ボタンをクリックし、データを保存した後に確認済リストボタンが押せなくなる!

ko.nakamura

総合スコア3

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

JavaScript

JavaScriptは、プログラミング言語のひとつです。ネットスケープコミュニケーションズで開発されました。 開発当初はLiveScriptと呼ばれていましたが、業務提携していたサン・マイクロシステムズが開発したJavaが脚光を浴びていたことから、JavaScriptと改名されました。 動きのあるWebページを作ることを目的に開発されたもので、主要なWebブラウザのほとんどに搭載されています。

0グッド

1クリップ

投稿2021/04/02 03:31

編集2021/04/03 01:33

##前提・実現したいこと
2/8より学習を開始したプログラミング初心者です。
スタッフ間で使用するオリジナルWebアプリ作成ています。
新商品の確認ボタン(『Webで確認』『実際に確認』の2個)と確認者リストボタン(『Webで確認の確認者リスト』『実際に確認の確認者リスト』のこちらも2個)を実装中です。
問題が起きているのは『実際に確認の確認者リストボタン』の方です。
『実際に確認』クリックしデータを保存して、いざ『確認者リストボタン』をクリックしようとしてもなぜか押せなくなってしまいます。
『実際に確認』クリックする前はちゃんと押せて、かつ確認者リストもプルダウンで表示されます。
ちなみにWebで確認の方は全ての動作が滞りなくできます

##該当のソースコード

html

1 <div class="confirmation_room"> 2 <div class="confirmation_contents"> 3 <div class="button"> 4 <% if @item.liked_by?(current_user) %> 5 <div>・確認済</div> 6 <span style="cursor: hand; cursor:pointer;"> 7 <div id="confirmed_list1">・確認者リスト</div> 8 </span> 9 <% else %> 10 <%= link_to "・webで確認", item_web_confirmations_path(item_id: @item.id), method: :post, remote: true, id: @item.id, class: 'confirmation_button', id: "confirmed1" %> 11 <span style="cursor: hand; cursor:pointer;"> 12 <div id="confirmed_list1">・確認者リスト</div> 13 </span> 14 <% end %> 15 </div> 16 </div> 17 <ul class="confirmed_lists hidden" id="pull_down1"> 18 <% @web_confirmations.each do |f| %> 19 <li class="pull_down_list" ><%= f.user.user_name %></li> 20 <% end %> 21 </ul> 22 <div class="confirmation_contents"> 23 <div class="button"> 24 <% if @item.liked_by?(current_user) %> 25 <div>・確認済</div> 26 <span style="cursor: hand; cursor:pointer;"> 27 <div id="confirmed_list2">・確認者リスト</div> 28 </span> 29 <% else %> 30 <%= link_to "・実際に確認", item_local_confirmations_path(item_id: @item.id), method: :post, remote: true, id: @item.id, class: 'confirmation_button', id: "confirmed2" %> 31 <span style="cursor: hand; cursor:pointer;"> 32 <div id="confirmed_list2">・確認者リスト</div> 33 </span> 34 <% end %> 35 </div> 36 </div> 37 <ul class="confirmed_lists hidden" id="pull_down2"> 38 <% @local_confirmations.each do |f| %> 39 <li class="pull_down_list" ><%= f.user.user_name %></li> 40 <% end %> 41 </ul> 42 </div> 43

javascript

1window.addEventListener('load', function(){ 2 3 //以下webの方の確認・確認者リストボタン 4 const confirmedList1 = document.getElementById("confirmed_list1") 5 const pullDownParents1 = document.getElementById("pull_down1") 6 const confirmed1 = document.getElementById("confirmed1") 7 8 confirmedList1.addEventListener('mouseover', function(){ 9 this.setAttribute("style", "color: red;") 10 }); 11 confirmedList1.addEventListener('mouseout', function(){ 12 this.removeAttribute("style", "color: white;") 13 }); 14 confirmedList1.addEventListener('click', function() { 15 if (pullDownParents1.getAttribute("style") == "display:block;") { 16 pullDownParents1.removeAttribute("style", "display:block;") 17 } else { 18 pullDownParents1.setAttribute("style", "display:block;") 19 } 20 }); 21 22 confirmed1.addEventListener('click', function() { 23 this.textContent = '・確認済'; 24 }); 25 confirmed1.addEventListener('mouseover', function() { 26 this.setAttribute("style", "color: red;") 27 }); 28 confirmed1.addEventListener('mouseout', function(){ 29 this.removeAttribute("style", "color: white;") 30 }); 31 32 33 34 //以下実際の方の確認・確認者リストボタン 35 const confirmedList2 = document.getElementById("confirmed_list2") 36 const pullDownParents2 = document.getElementById("pull_down2") 37 const confirmed2 = document.getElementById("confirmed2") 38 39 confirmedList2.addEventListener('mouseover', function(){ 40 this.setAttribute("style", "color: red;") 41 }); 42 confirmedList2.addEventListener('mouseout', function(){ 43 this.removeAttribute("style", "color: white;") 44 }); 45 confirmedList2.addEventListener('click', function() { 46 if (pullDownParents2.getAttribute("style") == "display:block;") { 47 pullDownParents2.removeAttribute("style", "display:block;") 48 } else { 49 pullDownParents2.setAttribute("style", "display:block;") 50 } 51 }); 52 53 confirmed2.addEventListener('click', function() { 54 this.textContent = '・確認済'; 55 }); 56 confirmed2.addEventListener('mouseover', function() { 57 this.setAttribute("style", "color: red;") 58 }); 59 confirmed2.addEventListener('mouseout', function(){ 60 this.removeAttribute("style", "color: white;") 61 }); 62});

##試したこと
データ保存後、何かの要素が覆い被さってしまっているのかと思いz-indexなどで試してみましたが変わりませんでした。
基本的に2つの確認ボタンはid名が違うだけなのになぜなのかがまたくわかりません。
しかもデータ保存後のみ、、
昨日夜から解決できていないので、ぜひお願いいたします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

yambejp

2021/04/02 04:06

初心者マークがつけられたと思うので、つけておいて損はないと思います
ko.nakamura

2021/04/02 04:16

ありがとうございます! 追加いたしました
winterboum

2021/04/02 10:00

確認済リストボタン が見当たりませんが? viewにある文字列と同じ物にしていただくとか、 「この行の」 とか誤解のない様に書いてください
ko.nakamura

2021/04/03 01:31

ご指摘ありがとうぎざいます! 確認者リストでしたので修正いたします。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問