Musievska
Issues with Alpine.js Tooltips and gettext Translation on Show Pages
Hello,
I’m currently facing an issue when using tooltips from Alpine.js in my Elixir Phoenix LiveView project. The tooltips are working perfectly fine on index pages but not on show pages. To work around this, I added an x-data attribute to handle tooltips like this:
<div class="ms-2" x-data="{ tooltip: 'Edit Dashboard' }">
<button
class="ti-btn ti-btn-light !py-3 ms-2"
type="button"
phx-click="toggleDetails"
phx-target="#dashboard_show"
phx-value-asset_id={@dashboard.id}
x-tooltip="tooltip"
>
<i class="fe fe-edit-3 text-xs"></i>
</button>
</div>
This works great for static text, but I need to translate the tooltip using gettext.
Does anyone know the best way to integrate gettext with Alpine.js tooltips or if there’s a better solution to make tooltips work on show pages?
Any help would be greatly appreciated :))
First Post!
cmo
It’s been a while since I used Alpine, but can’t you put an assign into the x-data attribute?
<div class="ms-2" x-data="{ tooltip: '<%= @tooltip %>' }">
<button
class="ti-btn ti-btn-light !py-3 ms-2"
type="button"
phx-click="toggleDetails"
phx-target="#dashboard_show"
phx-value-asset_id={@dashboard.id}
x-tooltip="tooltip"
>
<i class="fe fe-edit-3 text-xs"></i>
</button>
</div>
Or is it x-data={“{ tooltip: ' #{@tooltip}' "}?
Popular in Questions
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
What is the idiomatic way of matching for not nil in Elixir?
E.g.,
First way:
defp halt_if_not_signed_in(conn, signed_in_account) when...
New
Good day to you all.
I have been struggling to get a query involving like and ilike to work.
Can anyone assist me on this, please?
pro...
New
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this:
...
New
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database.
Dep...
New
I would like to know what is the best IDE for elixir development?
New
Hello,
I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these
buyer = %{
id: ...
New
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work.
Or rather, not char, but a substr...
New
Other popular topics
Update:
How to use the Blogs & Podcasts section
You can post links to your blog posts or podcasts either in one of the Official Blog...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
Credo is smart enough to check for (something like) this:
assert length(the_list) == 0
with this response:
Checking if an enum is empt...
New
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
Good day to you all.
I have been struggling to get a query involving like and ilike to work.
Can anyone assist me on this, please?
pro...
New
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine)
This is a plugin that adds support for Elixir to JetBrains IntelliJ...
New
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
Hi,
I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
Hello guys,
I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New








