0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

1ページに複数のモーダル

Posted at

1ページに複数のモーダル

1ページに複数のモダールを実装するには、dialogタグに id="modal1"を書き、buttonのopenの方にdata-modal-target="modal1"を指定する必要がある。

app/views/companies/search.html.erb

<%# 1つ目モーダル %>
<div data-controller="modal">
 <dialog id="modal1" data-modal-target="dialog" class="bg-[#f7f8fb] p-8 rounded-lg m-auto backdrop:bg-black/80">


<button type="button" data-action="modal#close"   class=" mt-5 px-4 py-1 bg-white text-[#143993] font-bold text-sm  border-2 rounded-full">
          この条件を追加する
        </button>
        
      
    </div>
  </dialog>

  <button data-action="modal#open" data-modal-target="modal1"class="   text-base ">所在地を選択</button>


<%#  2つ目モーダル %>
 <div data-controller="modal">
  <dialog id="modal2" data-modal-target="dialog" class="bg-[#f7f8fb] p-8 rounded-lg m-auto backdrop:bg-black/80">


<button type="button" data-action="modal#close"   class=" mt-5 px-4 py-1 bg-white text-[#143993] font-bold text-sm  border-2 rounded-full">
          この条件を追加する
        </button>
       
  </dialog>

  

  <button data-action="modal#open" data-modal-target="modal2" class="   text-base ">業種を選択</button>
</div>

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?