Google Groups

Re: [Lift] Ajax without bind


Emmanuel Eytan Apr 27, 2012 10:48 AM
Posted in group: Lift
Actually, I'm have a new problem with this:

In my snippet, I have:

      ".my-button [onclick]" #> SHtml.ajaxInvoke(() => {
        SetHtml("%s-status".format(a.id.is), <span>Changed</span>) &
        () => a.myValue(Changed)
      }

And that yields the following error:

[error] /home/eeytan/verawebsite/src/main/scala/code/snippet/MySnippet.scala:34: type mismatch;
[error]  found   : () => code.model.MyModel
[error]  required: net.liftweb.http.js.JsCmd
[error]         {() => a.myValue(Changed)}
[error]             ^
[error] one error found

When it was println, Lift was okay with it, even though println is not a JsCmd, but when I try to use the ajaxInvoke to change a mapped value, Lift says that my model is not a JsCmd. I've looked at all the JsCmds in the documentation and I can't seem to be able to find one that fits.

On Friday, April 27, 2012 1:28:42 PM UTC-4, fmpwizard wrote:
Yes, once you get the Lift way, doing advance things ends up pretty
simple, of course, it takes time to get there, but this is why we have
the mailing list, to help each other get there.

  Diego

On Fri, Apr 27, 2012 at 12:59 PM, Emmanuel Eytan <eje...@gmail.com> wrote:
> This is like pretty much everything in Lift: very hard to figure out and
> extremely easy to use. It's so incredibly simple that I can hardly remember
> how completely baffled by it I was fifteen minutes ago.
>
> Yes, that is exactly what I needed and I can do what I would have done with
> another framework with about one twentieth of the code.
>
> I'm so glad I picked Lift!
>
>
> On Friday, April 27, 2012 12:21:54 PM UTC-4, fmpwizard wrote:
>>
>> On Fri, Apr 27, 2012 at 12:16 PM, Emmanuel Eytan <eje...@gmail.com> wrote:
>> > Thanks! This is EXACTLY what I need. And I'm not sure I would have
>> > figured
>> > it out without your help.
>> >
>> > I'm still missing one last part: how I do make it do Lift stuff rather
>> > than
>> > client-side stuff? How can I get Ajax to call a Lift function? Do I have
>> > to
>> > go through actors or REST for that?
>> >
>>
>> No actors or RESt needed here
>>
>> from
>> http://blog.fmpwizard.com/scala-lift-custom-wizard
>>
>> there is this snippet of code
>> https://gist.github.com/1692799
>>
>> The line
>>
>> info("Data confirmed!")
>>
>> is code running in the lift server
>>
>> so that could be the call to your
>>
>> def mySuperMethod ={
>>   println("This is called from the web and executed on the lift server")
>> }
>>
>> Does that make sense ?
>> Regards,
>>
>>   Diego
>>
>>
>>
>> > On Friday, April 27, 2012 11:58:03 AM UTC-4, fmpwizard wrote:
>> >>
>> >> You are in luck, just last night I got a really simple  sample on
>> >> github
>> >> https://github.com/fmpwizard/ajaxInvoke
>> >>
>> >> Feel free to ask questions about it.
>> >>
>> >> Regards,
>> >>
>> >>   Diego
>> >>
>> >> On Fri, Apr 27, 2012 at 11:52 AM, Emmanuel Eytan <eje...@gmail.com>
>> >> wrote:
>> >> > Hi. I'm at last adding some Ajax to my Lift project. But all the
>> >> > examples I
>> >> > find use bind. I was told previously on this forum that bind was
>> >> > deprecated.
>> >> > Is that also true of AjaxForm?
>> >> >
>> >> > Basically, I'm looking for a button that would do something like run
>> >> > a
>> >> > function exampleFunction such as:
>> >> >
>> >> > def render = {
>> >> >   def exampleFunction(a: AMappedThing) =
>> >> >     a.someProperty("someValue").save
>> >> >
>> >> >   "ul *" #> AMappedThing.findAll().map(a =>
>> >> > <li><p>{a.name}</p><button>Change</button></li>) &
>> >> >   "the button I just created" #>
>> >> > onClick(exampleFunction(the_a_that_matches_each_button:
>> >> > AMappedThing))
>> >> > }
>> >> >
>> >> > How can I generate an Ajax button for each element found that will
>> >> > know
>> >> > which element it's attached to? I was thinking of using andThen and
>> >> > modifying the element I just created, but that looks messy. How do I
>> >> > link a
>> >> > Lift function to an Ajax call? Do I need actors for that?
>> >> >
>> >> > Thanks.
>> >> >
>> >> > --
>> >> > 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
>> >>
>> >>
>> >>
>> >> --
>> >> Diego Medina
>> >> Lift/Scala Developer
>> >> di...@fmpwizard.com
>> >> http://www.fmpwizard.com
>> >
>> > --
>> > 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
>>
>>
>>
>> --
>> Diego Medina
>> Lift/Scala Developer
>> di...@fmpwizard.com
>> http://www.fmpwizard.com
>
> --
> 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



--
Diego Medina
Lift/Scala Developer
di...@fmpwizard.com
http://www.fmpwizard.com