This code does what I think you want:

package com.liftcode.snippet

import _root_.scala.xml.{NodeSeq, Text}
import _root_.net.liftweb.util._
import _root_.net.liftweb.common._

import com.liftcode.lib._
import Helpers._
import _root_.net.liftweb.http._
import js._
import JsCmds._
import JE._

class HelloWorld {

  private def processAjaxCall(in: String): JsCmd =
  SetHtml("fruit_bat", <span>The id is {in}</span>)

  def howdy(in: NodeSeq): NodeSeq =
  for {
    i <- 1 to 20
  } yield <div><a id={"id_"+i} onclick={SHtml.ajaxCall(JsRaw("this.id"),
processAjaxCall)._2.toJsCmd+"; return false;"}>Click me #{i}</a></div>

}



On Sun, Nov 15, 2009 at 3:07 PM, Chris Lewis <[email protected]>wrote:

>
> Hello list,
>
> Often in an AJAX handler I need to update something on the client side;
> usually a UI control that initiated the handler. The only way I know to
> handle this is to generate a DOM id in the snippet during a rendering
> call (like a bind() call in a flatMap over a dataset), look for that id
> in my handler, and then query up or down the DOM to find the
> corresponding UI component to tweak. It'd be nice if I could access the
> event source node in my handler. In a standard JS event handler, 'this'
> references the source element, and in some JS libraries like prototype,
> a method is added to the event object to access the source element.
>
> Given the current implementation, what's the best way to access the
> client side source of a UI event in a server-side handler? It seems like
> there'd be a cleaner way than what I'm doing. Thanks!
>
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<liftweb%[email protected]>
> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.


Reply via email to