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

Feature request for turbo frame? #509

Closed
swamidass opened this issue Jan 4, 2022 · 3 comments
Closed

Feature request for turbo frame? #509

swamidass opened this issue Jan 4, 2022 · 3 comments

Comments

@swamidass
Copy link

swamidass commented Jan 4, 2022

Is there a way to get turboframe to append elements to an existing turboframe? If not, this might be a useful feature. Of course, if I'm missing how to do this, please let me know.

I'm using lazy loading of turboframe as an infinite pager with lazy loading. It works great. But to the downside is that it can't put the new elements in the same container. That's a big downside in that it prevents useful layout options I'd like to take advantage of.

To give some more specificity, each page is setup like this:


<turbo-frame id="__pagination{{ $pagenumber }}" target="_top> 
   {{ ELEMENTS FOR THIS PAGE }}
</turbo-frame>

<turbo-frame id="__pagination{{ $nextpagenumber }}" src="{{ $nextpageurl }}" loading=lazy data-turbo-action="advance" target="_top">
</turbo-frame>

Or...

<turbo-frame id="__pagination{{ $pagenumber }}" target="_top> 
    {{ ELEMENTS FOR THIS PAGE }}

  <turbo-frame id="__pagination{{ $nextpagenumber }}" src="{{ $nextpageurl }}" loading=lazy data-turbo-action="advance" target="_top">
  </turbo-frame>
</turbo-frame>

On infinite scroll, the next items fill in the place holder like this:

<turbo-frame id="__pagination{{ $pagenumber }}" target="_top> 
   {{ ELEMENTS FOR THIS PAGE }}
</turbo-frame>

<turbo-frame id="__pagination{{ $nextpagenumber }}" src="{{ $nextpageurl }}" loading=lazy data-turbo-action="advance" target="_top">
     {{ ELEMENTS FOR NEXT PAGE }}
</turbo-frame>

<turbo-frame id="__pagination{{ $nextnextpagenumber }}" src="{{ $nextnextpageurl }}" loading=lazy data-turbo-action="advance" target="_top">
</turbo-frame>

So...is there a way to have setup so it fills in like this?

<turbo-frame id="__pagination{{ $pagenumber }}" target="_top> 
   {{ ELEMENTS FOR THIS PAGE }}
   {{ ELEMENTS FOR NEXT PAGE }}
</turbo-frame>

<turbo-frame id="__pagination{{ $nextnextpagenumber }}" src="{{ $nextnextpageurl }}" loading=lazy data-turbo-action="advance" target="_top">
</turbo-frame>

Of course, where the turboframe to the next page lands is not important in the end, because it is a hidden element.

@seanpdoyle
Copy link
Contributor

seanpdoyle commented Jan 4, 2022

Could this be resolved by some of the changes proposed in #146 or #431?

@swamidass
Copy link
Author

Seems like that this would be resolved by #146. Is there a good reason that pull request wasn't accepted?

@brunoprietog
Copy link
Collaborator

Hi @swamidass, there's no plan to add this at least for now. In this particular case, you would be better off using a Turbo stream to solve this. You can even include Turbo streams inside the response if it is inside a Turbo frame, so that you still have the lazy loading. Closing this for now

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

No branches or pull requests

3 participants