Hi David. Yes, that's perfect.
Thanks. Lance On Jun 2, 6:10 pm, David Pollak <feeder.of.the.be...@gmail.com> wrote: > Try: > <lift:foo.myFoos> > <foos:list> > <div foo:div_id="xxx"> > <foo:id/> > </div> > </foos:list> > </lift:foo.myFoos> > > In your bind: > > def doFoo(in: NodeSeq): NodeSeq = List("a", "b", "c").zipWithIndex.flatMap { > case (str, idx) => > bind("foo", "id" -> str, AttrBindParam("div_id", Text("my_foo_"+idx), > "id)) > > } > > bind("foos", xhtml, > "list" -> doFoo _) > > The AttrBindParam will bind to an attribute and let you create a value and a > new name for the attribute. > > Does this help? > > On Tue, Jun 2, 2009 at 8:01 AM, Lance Walton > <lance.c.wal...@googlemail.com>wrote: > > > > > > > Hi. > > > I'm still trying to grok your example :-) In the meantime, I'll try to > > give a bit more context. > > > If I have this template: > > > <lift:foo.myFoos> > > <foos:list> > > <div id="foo_foo:id"> > > <foo:id/> > > </div> > > </foos:list> > > </lift:foo.myFoos> > > > Then when I munge it all, given foos with ids 12, 57 and 132, I'll get > > XML like this: > > > <div id="foo_foo:id"> > > 12 > > </div> > > <div id="foo_foo:id"> > > 57 > > </div> > > <div id="foo_foo:id"> > > 132 > > </div> > > > etc. > > > What I want is XML like this: > > > <div id="foo_12"> > > 12 > > </div> > > <div id="foo_57"> > > 57 > > </div> > > <div id="foo_132"> > > 132 > > </div> > > > The reason I want this is because I have some ajax stuff going on > > which will do something with one of the foos and then replace the > > corresponding div with the updated version. Hence I need to be able to > > identify the div and the foos id seems the most natural thing to use. > > > Many of the examples snippets I've seen embed fragments of XML (which > > I don't object to from a pragmatic point of view). I do find it a > > little strange though, since pains have clearly been taken to keep > > control logic out of the view, but now we're putting bits of view into > > the control logic. > > > Once again, I'm just starting with this stuff, so I'm assuming that I > > don't understand something, rather than making the arrogant assertion > > that something is wrong with Lift :-) > > > Regards, > > > Lance > > > On Jun 2, 3:09 pm, Timothy Perrett <timo...@getintheloop.eu> wrote: > > > Try: > > > > bind("foo", chooseTemplate("foos", "list", xhtml), > > > "id" -> <div>example</div> % "id" -> foo.id.toString, > > > ..... > > > ) > > > > Without a bit more context / code its tough to help exactly - but from > > > this example you'll see how you can create dynamic attributes. > > > > Cheers, Tim > > > > On Jun 2, 2:59 pm, Lance Walton <lance.c.wal...@googlemail.com> wrote: > > > > > Hi. > > > > > I've seen a few threads about binding attribute values, but none of > > > > the solutions seem relevant for my problem. I am a Lift and Scala > > > > beginner, so I'm most likely missing something obvious. > > > > > I have the following template: > > > > > <lift:foo.myFoos> > > > > <foos:list> > > > > <div id="foo_foo:id"> > > > > ... > > > > </div> > > > > </foos:list> > > > > </lift:foo.myFoos> > > > > > and here is the piece of my Foo snippet to do with binding: > > > > > def myFoos(xhtml : NodeSeq) : NodeSeq = foos.flatMap(foo => > > > > bind("foo", chooseTemplate("foos", "list", xhtml), > > > > "id" -> foo.id, > > > > ...)) > > > > > What I want is for the id attribute in the div in the template to be > > > > given the value foo_1, foo_2, etc, depending on the value of foo.id in > > > > the snippet. What I get is foo_foo:id (and removing the 'foo_' part > > > > doesn't change anything). > > > > > Can anybody help? > > > > > Regards, > > > > > Lance > > -- > 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 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---