On Tue, Jun 2, 2009 at 7:51 AM, Philipp Meier <phme...@gmail.com> wrote:

>
> On Jun 2, 3:56 pm, David Pollak <feeder.of.the.be...@gmail.com> wrote:
> > On Tue, Jun 2, 2009 at 2:20 AM, Philipp Meier <phme...@gmail.com> wrote:
> > > I'm exploring AJAX with lift and have a basic question. If I have
> > > several snippets on a page that use a shared session-variable (think
> > > of a shopping cart and a control to add a product to the cart). How
> > > can the control snipped trigger a AJAX rerender of the cart snippet
> > > after the cart was changed? I'm sure by making both the control and
> > > the cart an comet snippet this would be possible. However I wonder if
> > > there is another way.
>
> > > Second question: should the cart and the control be to different
> > > snippets or can I implement two methods to render the cart snippet:
> > > one method to render the "list of items" another to render a
> > > controller to place a certain product into the cart.
> >
> > I would have a single method that renders the HTML for the shopping cart.
> >  This way, the above SetHtml() scheme would work well (note that if
> you're
> > doing a shopping cart might often contain hundreds of items, I wouldn't
> > re-render the whole cart each time it's changed, I'd do some partial
> > updating... or even client-side rendering and the Ajax would send
> JavaScript
> > that updates a client-side JavaScript object that holds the cart's
> > contents.)  But for a shopping cart that typically holds < 10 items,
> doing a
> > complete redraw each time is not going to be that bad.
>
> To make sure I got it right. You write about a single method to render
> ther cart. Are you sure? It think you need a Cart.list to create the
> list div. And a Cart.control,which will parametrized with the product
> id, for the "add-to-cart" control. The control will trigger the cart-
> update which itself will trigger the rerender of the cart. Or did I
> misunderstand you?


Please see http://liftweb.net/docs/getting_started/mod_master.html

This steps you through an application that has Ajax-based updating of the To
Do list.  The structure of a shopping cart should be the same as the
structure of the To Do list, except the items in the list are "things to
buy" rather than "things to do".

Thanks,

David


>
>
> Thanks,
>
> Philipp Meier
>
> --
> Gras doesn't grow faster by tearing at it.
>
> > > --
> > > Gras doesn't grow faster by tearing at it.
> >
> > --
> > Lift, the simply functional web frameworkhttp://liftweb.net
> > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > Follow me:http://twitter.com/dpp
> > Git some:http://github.com/dpp
>
> >
>


-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to