[Lift] Accessing innerHTML during bind?

2010-02-03 Thread Tim Maxwell
Hi folks,

I am trying to do binds based on a list of products. The point is to
create links that can be wrapped around existing text or images.
Something like this:

This is the link text our marketing dept.
creates

Here's what I have so far in the snippet related to it:

 def links(html:NodeSeq): NodeSeq={

val productBinds:Seq[BindParam] = Product.findActive.flatMap{
  prod => List[BindParam] (  TheBindParam( "force_"+prod.product,
SHtml.link("/forced?product="+prod.product, ()=>() , _ ) )  )
}
bind("links" , html, productBinds: _*)

  }

Cheers,
Tim

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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.



Re: [Lift] Accessing innerHTML during bind?

2010-02-03 Thread David Pollak
On Wed, Feb 3, 2010 at 12:44 PM, Tim Maxwell  wrote:

> Hi folks,
>
> I am trying to do binds based on a list of products. The point is to
> create links that can be wrapped around existing text or images.
> Something like this:
>
> This is the link text our marketing dept.
> creates
>
> Here's what I have so far in the snippet related to it:
>
>  def links(html:NodeSeq): NodeSeq={
>
>val productBinds:Seq[BindParam] = Product.findActive.flatMap{
>  prod => List[BindParam] (  TheBindParam( "force_"+prod.product,
> SHtml.link("/forced?product="+prod.product, ()=>() , _ ) )  )
>}
>bind("links" , html, productBinds: _*)
>
>
It's so cool to see how people stuff in Lift...

Within your function, you can get the element that's being bound with:

BindHelpers.currentNode: Box[Elem]

On the other hand, if you're looking to get the children of the node
currently being bound:

 FuncBindParam("force_"+prod.product, body => {body})

Hope this helps.

Thanks,

David


>  }
>
> Cheers,
> Tim
>
> --
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To post to this group, send email to lift...@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.
>
>


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

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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.