bitbldr

bitbldr

Hello!

I’m having trouble using Bootstrap tooltips inside a Phoenix LiveView. I have verified that the tooltips work just fine on the same page outside of the LiveView in the eex template, but when placed inside of a LiveView render function they do not seem to work. I’m wondering if this is something related to browser events not making their way to the underlying Popper.js listeners due to Phoenix or if it is simply not possible to do something like this inside of LiveView, which would be a shame because LiveView has been wonderful in so many other ways.

Here is an abbreviated snippet of my code:

  def render(assigns) do
    ~L"""
        ...


        <button type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="top" title="Tooltip on top">
          Tooltip on top
        </button>

      ...
      """

What I have tried so far without success…

  1. Standard tooltip initialization from the eex template
  <body>
    ...

    <script>
    $(function () {
      $('[data-toggle="tooltip"]').tooltip();
    });
    </script>
  </body>
  1. Phoenix hook using phx-hook=“TooltipInit”
export const TooltipInit = {
  mounted() {
    const id = this.el.getAttribute('id');
    $('#' + id).tooltip();
  },
};

  1. Adding script tag with initialization directly in the LiveView render
  2. Calling initialization directly in browser console
> $('[data-toggle="tooltip"]').tooltip();
w.fn.init [button.btn.btn-secondary]

The codebase heavily leverages bootstrap for styling and themes, so we aren’t really in a position to switch away from bootstrap as our main framework. Any help or advice would be greatly appreciated.

Thanks!

Showing Posts 1 to 4

AndyL

AndyL

Perhaps this blog post on ‘Bootstrap Native’ would be useful…

I’m curious to learn what you find please report back on your progress!!

mindok

mindok

Have you tried adding phx-update="ignore" to your button? Liveview manipulates the DOM so clashes with any other JS trying to manipulate the DOM. phx-update="ignore" tells LiveView not to mess with that element and its children.

andreaseriksson

andreaseriksson

Can confirm that Bootstrap native is a good option. Its time to loos that JQuery anyway :smile:

bitbldr

bitbldr OP

Thanks everyone! Adding phx-update="ignore" to the button’s parent div worked like a charm.

I quickly tried using BSN as well, but I couldn’t get it working and quickly gave up given the other solution. Maybe sometime in the future we can switch over or just upgrade to BS 5 with no jquery dependency :grinning:

— All posts loaded —

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews