And David beat me to it... Oh well :)

On Tue, Nov 25, 2008 at 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 an attribute on a model object in the database via AJAX
>> when a checkbox is clicked on a page. I presume that ajaxCheckbox is for
>> this purpose.
>>
>> Can anyone quickly give me an example of how it works?
>>
>> If I have an attribute called isActive, how would I create an
>> ajaxCheckbox that would call a method on the server when the checkbox is
>> clicked to set isActive to true or false, depending on the state of the
>> checkbox after the click?
>>
>> bind("mine", xhtml,
>>   "isActive" -> SHtml.ajaxCheckbox(thing.isActive, ???)
>>
>> What about selecting the day of the week from an ajaxSelect and updating
>> dayOfWeek. Or, finally, updating a text field on blur and setting the
>> user_name.
>>
>> Examples would really help.
>>
>> I am pretty desperate to have this done today, and several hours of
>> playing with various combinations has left me befuddled. Doesn't help
>> that it's 4 AM.
>>
>> Any and all help very greatly appreciated.
>>
>> Thanks,
>> Chas.
>>
>> >>
>>
>

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