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

Duplication of injected JS for nested async templates #116

Closed
vanboom opened this issue May 15, 2020 · 1 comment
Closed

Duplication of injected JS for nested async templates #116

vanboom opened this issue May 15, 2020 · 1 comment

Comments

@vanboom
Copy link

vanboom commented May 15, 2020

I have a tabbed UI where a CREATE action can add tabs. The tabs are dynamically loaded using render_async when the user clicks on the tab label. Consider something like this...

targetprocess-screen-capture (6)

Each tab is loaded asynchronously, so the view layout contains:

= content_for(:render_async)

However, because the CREATE function can add a new tab to the UI, the asynchronous view partial also contains:

= content_for(:render_async)

This is causing duplication of the injected Javscript when the view is rendered because it is being injected at the layout level and within the partial for each tab.

Possible solution: what if the render_async method accepted an option to specify the content tag? This would provide control over where the injected Javascript would go. Of course, the option would default to :render_async for backward compatibility. I will experiment with this on my fork and offer a PR if I can get something working.

vanboom pushed a commit to vanboom/render_async that referenced this issue May 15, 2020
nikolalsvk added a commit that referenced this issue Jun 14, 2020
wip #116 allow a custom content_for name
@nikolalsvk
Copy link
Owner

This should now be possible to avoid with 2.1.7 version! Big thanks to @vanboom for making a feature of customizing content_for name a reality 🍰 🎉 !

BTW, there is also a Discord channel where you can post suggestions and get help quickly. I'd be happy to see you there as well. 💚

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