[Seaside] Someone having tabs with Seaside html+js cached on localStorage?

Johan Brichau johan at inceptive.be
Fri Mar 10 17:56:01 UTC 2017


> On 10 Mar 2017, at 16:34, Mariano Martinez Peck <marianopeck at gmail.com> wrote:
> 
> I haven't thought about that one. Seems like a good idea. Let me ask...when you need to open a new tab (say a main menu button was clicked), how do you avoid having to re-render all the "workspace" (all tabs) ?  Do you only render the new one and do an append() or something?

The easiest is when you _can_ render all tabs at once, but if that gets to heavy (as Esteban is mentioning), you should do it lazily, which means doing ajax requests when necessary.
I cannot really copy/paste any code for this, but let me try to outline what I would do:

- Each of the tabs should be Seaside components, nested inside a ‘window’ component that holds onto all the tabs.
- When you render the page, the ‘window’ component renders the open tab and does not render anything for the others.
- The tab controls are implemented using javascript and when you click a new tab, this code checks if the tab is on the page and if it’s not it asks the server to render it via an ajax request and appends the generated html to the page in the correct location, followed by a hide() and show().
- One way we do this is generate <div> elements with a unique id that identifies the tab component. If the div is empty, we launch a callback with the id as an argument and our Seaside component then knows which component to render. That just requires you to keep a dictionary of components in the ‘window’ component with mappings id -> tab component.

So… basically what you already had in mind, but using the DOM as the place to store the tab html instead of somewhere else.

My guess is that the hardest problem is to know when you need to rerender a tab’s html (based on changes on the server…) instead of just showing the content already on the page.

Johan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/seaside/attachments/20170310/7a892b0a/attachment.html>


More information about the seaside mailing list