Bootstrap data-toggle in phoenix eex template

I am using bootstrap 4 on my phoenix project and I wanted to use the modal class which when defined there is a data-toggle attribute i.e data-toggle="modal" but I can’t use the data-toggle in my .eex template. Does anyone know how I can get through this? thanks

I would say that You can… I am for example using data-dismiss in eex template.

<div class="alert alert-<%= @mode %> alert-dismissible fade show" role="alert">
  <%= @message %>
  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true">&times;</span>

I have also implemented modal with success.

Is it a js problem? What code did You put in eex?

<%= link "NEW TRADER", to: trader_path(@conn, :new), class: "btn btn-success m-b-sm", data-toggle="modal" %>

which tells me syntax error before: data

Try to use

"data-toggle": "modal"
1 Like

this works well. thank you