Open tanthammar opened 4 years ago
Gonna check it. I also need to update the package assets.
I finally solved it. Do not think (but not sure) if it was related to this package. I included the latest versions, via cdn. And I had to add window event listeners for Turbolinks and Laravel Livewire, and call tippy.
@tanthammar I'm using Livewire as well - any hints for making this work with it would be greatly appreciated!! Thanks
@ulfie22 I actually skipped this package because I needed to reactivate it when turbolinks has finished loading and livewire redraws the component. Made a blade component instead that I have on my app.blade.php
<script src="https://unpkg.com/@popperjs/core@2"></script>
<script src="https://unpkg.com/tippy.js@6"></script>
<script>
document.addEventListener('turbolinks:load', () => {
tippy('[data-tippy-content]');
});
window.livewire.hook('afterDomUpdate', () => {
tippy('[data-tippy-content]');
});
</script>
Then in any blade file:
<anytag data-tippy-content="some tooltip"></anytag>
<anytag data-tippy-content="{{ $some_var }}"></anytag>
<anytag data-tippy-content="{{ $some_method() }}"></anytag>
@tanthammar Thanks for the very complete explanation!! Livewire is really awesome but I've run into some issues trying to execute my javascript within it - I'll try this approach. Thanks again for the quick complete reply!!
Thanks for the tip Tanthammar. I came across your post for the tippy issue rather than turbolinks issue, and for anyone else who might be in the same situation in my case I had to wrap your script:
window.livewire.hook('afterDomUpdate', () => { tippy('[data-tippy-content]'); });
within:
document.addEventListener("livewire:load", function(event) {}
as mentioned at https://laravel-livewire.com/docs/lifecycle-hooks
@neodisco That is strange, on my end it works without that wrapper.
For anyone else who happens upon this, I got it to work like this:
document.addEventListener("DOMContentLoaded", () => {
Livewire.hook('element.initialized', (el, component) => {
tippy('[data-tippy-content]');
})
});
I have a table with icons in a td. I have wrapped an svg icon with the Popper tag.
The tooltip is only visible on the first row in the table. The following rows does not show any tooltip.
This is in my blade file
This is the generated html