SCALA Lift - Call javascript with params from Comet actor
I'm trying to get a comet class to call some javascript with params but can't seem to find the right way to go about it.
So far I have:
case class StreamItem(name: String, path: String, level: String)
class StreamComet extends CometActor with CometListener {
private var streams: List[StreamItem] = Nil
def registerWith = StreamServer
override def lowPriority = {
case v: List[StreamItem] => streams = v; reRender()
}
def render = {
"li *" #> streams.map(stream =>
".name *" #> stream.name &
".stream [id]" #> stream.path.toString
)
}
}
object StreamServer extends LiftActor with ListenerManager {
private var streams: List[StreamItem] = Nil
def createUpdate = streams
override def lowPriority = {
case stream: String if stream.length > 0 =>
streams :+= StreamItem("James", stream, "_1");
updateListeners()
}
}
What I need to do now开发者_运维百科 is call a javascript function, already defined, with the newly added stream. So when the ajax form is submitted and the value sent to the StreamServer, somewhere in the StreamComet render method I need to call the javascript function with that particular item in the streams list as to update the DOM. Not sure if this is the correct way to go about it though.
Any help is much appreciated, thanks in advance
You can try
import net.liftweb.http.js.JE.JsRaw
JsRaw("myJSFunction(myParam)").cmd
精彩评论