navigation and snippet vars

23 views
Skip to first unread message

Andrzej Skalski

unread,
Aug 20, 2015, 1:11:42 PM8/20/15
to Lift
Hi,

while working on my app, I used to used to write things like this (scenario is some Record):

object ScenarioEditSnippet extends Loggable {

 
object varScenarioToEdit extends SessionVar[Box[AScenario]](Empty)

 
def getBodyFor(scen : AScenario) : NodeSeq = {
   
<ul>
     
{
        scen
.getContentsIds.map(x => <li>{x.toString}</li>) toSeq
     
}
   
</ul>

  }

  def getBody : NodeSeq = {
    varScenarioToEdit.get match {
      case Full(scen) => getBodyFor(scen)
      case _ => <div> no stuff </
div>
   
}
 
}

 
def render = {
   
"#putBodyHere" #> getBody
 
}
}

there is usually a site "edit_scenario.html" that contains this snippet, and I navigate to it with "ajaxButton" setting the var.

I am wondering if this is a good way to do it? Or what is the preffered way to pass arguments to snippets on sub-pages? Via S.param ?

Andrzej

Diego Medina

unread,
Aug 23, 2015, 9:44:40 PM8/23/15
to Lift

This way is fine, nothing wrong with it

Diego
Sent from my cell

--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages