The return type is JsCmd because 80% of the time the Ajax command causes 
some update top be sent to the browser.  So, the special case is a Noop 
(sometimes I do an implicit Unit -> Noop) and the default case is returning 
the code to be rendered in the browser.

On Nov 25, 2008 5:04 AM, "Jorge Ortiz" <[EMAIL PROTECTED]> wrote:

You're almost there. The second parameter to ajaxCheckbox is a function that 
gets called on the server when the checkbox changes:

  SHtml.ajaxCheckbox(thing.isActive, (toggled: Boolean) => 
{thing.setActive(toggled); Noop})

The Noop is needed because ajaxCheckbox expects a Boolean => JsCmd function. 
(I can't find a good reason for it needing a JsCmd though... Shouldn't it 
just be Boolean => Any or better yet Boolean => Unit?) Howver, you can 
replace "thing.setActive(toggled)" with whatever code you want to run when 
the checkbox is toggled. Here, "toggled" contains the state of the checkbox.

Likewise ajaxSelect:

  val daysOfWeek = List("Monday", "Tuesday", "Wednesday", "Thursday", 
"Friday",
    "Saturday", "Sunday").map(x => (x, x))
  SHtml.ajaxSelect(daysOfWeek, Full("Monday"), (opt: String) => 
{thing.setDayOfWeek(opt); Noop})

The second parameter is the default value. The "opt" in the third parameter 
will correspond to the selected day.

--j

On Tue, Nov 25, 2008 at 4:11 AM, Charles F. Munat <[EMAIL PROTECTED]> wrote: > 
> > I want to update a...


--~--~---------~--~----~------------~-------~--~----~
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