Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initializing Foundation on Rails-7 Turbo Frames not working inside turbo-frames #12485

Open
chmich opened this issue Sep 26, 2022 · 1 comment

Comments

@chmich
Copy link

chmich commented Sep 26, 2022

Description

Rails-7 has launched the hotwired/turbo.
see Handbook
well explained on Hotrails

normally i initialize foundation with a code piece like this

$(document).on('turbo:render', function() { //=> first trigger on click a turbo-link
    onPageLoad();
});
$(document).ready(function () {
    onPageLoad();
});

function onPageLoad() {
    $(document).foundation();
}

This works if no turbo-frame is applied because by default, if the turbo-drive finds no turbo-frame, it replaces the body which triggers the turbo:render (previous that was anything like turbolinks:load)

The Problem

But, if Turbo is applied like thought or explained on Hotrails there's not running any of the above showed triggers, so foundation is not initialized inside the Frame.

What i have tried

I tried something like $('#mainFrame').foundation(); and hoped that Foundation would be initialized within the Frame with the ID "mainFrame" but did'nt work.

What should happen?

It should be possible to initialize Foundation within a special element, like i've tried.

What happens instead?

So, all Elements that needs to be initialized don't working inside a turbo Frame without replace the whole page.

Possible Solution

Please, make something like $('#mainFrame').foundation(); working, thanks!

Best Regards,
Christian

Test Case and/or Steps to Reproduce (for bugs)

I can upload you my rails project?

Test Case:

How to reproduce:
1.
2.
3.

Context

...

Your Environment

  • Foundation version(s) used:
  • Browser(s) name and version(s):
  • Device, Operating System and version:
  • Link to your project:

Checklist

  • [ x] I have read and follow the CONTRIBUTING.md document.
  • [ x] There are no other issues similar to this one.
  • [x ] The issue title and template are correctly filled.
@weiserma
Copy link

weiserma commented Nov 7, 2022

+1 when using tabs in Foundation 6, the tab contents are not visible when selecting tab after a frame reload. Contents are there but cannot display unless I reload page or use "" on the console.

Tab Contents before turbo load:
<div class="tabs-panel is-active" id="group-tabpanel1" role="tabpanel" aria-labelledby="group-tabpanel1-label"> ... </div>

Tab contents after turbo load:
<div class="tabs-panel " id="group-tabpanel1"> ... </div>

I expect the tabs-panel not to be active after turbo load but still should be a way to-reinitialize foundation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants