ajaxCall with multiple parameters

191 views
Skip to first unread message

joe

unread,
Jun 22, 2011, 4:45:26 PM6/22/11
to lif...@googlegroups.com
Hi, I was wondering if it is possible to send multiple variables through an ajaxCall. As an example, this is the code I have right now:

def inputs = {
    ".inputfield [onkeyup]" #> SHtml.ajaxCall(JsRaw("this.value"),
      s => { ... }
    )
}

but the class .inputfield will apply to a number of input boxes. I want to take the id of the .inputfield target as well, but it seems I can only take "this.value" OR "this.id".
What I mean is that I want to do something like:

def inputs = {
    ".inputfield [onkeyup]" #> SHtml.ajaxCall(JsRaw("this.value", "this.id"),
      (s, t) => { ... }
    )
}

This doesn't work of course because ajaxCall's second parameter is How would I go about doing something like this in lift?

I've tried sending "this.value+this.id" but because this.id is an unknown value I wouldn't know how to parse for it.

Thanks a lot, I appreciate any help.
Joe

Diego Medina

unread,
Jun 26, 2011, 11:07:44 AM6/26/11
to lif...@googlegroups.com

I do something similar to concatenate then, but I separate the with a |  to easily parse them

Sent from my cell
Diego Medina

> --
> You received this message because you are subscribed to the Google Groups "Lift" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/liftweb/-/y5O1UCGGOngJ.
> To post to this group, send email to lif...@googlegroups.com.
> To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
>

joe

unread,
Jun 27, 2011, 8:42:44 AM6/27/11
to Lift
Thanks, that's working for me.

On Jun 26, 11:07 am, Diego Medina <di...@fmpwizard.com> wrote:
> I do something similar to concatenate then, but I separate the with a |  to
> easily parse them
>
> Sent from my cell
> Diego Medina

David Pollak

unread,
Jun 27, 2011, 2:11:22 PM6/27/11
to lif...@googlegroups.com
On Mon, Jun 27, 2011 at 5:42 AM, joe <pha...@gmail.com> wrote:
Thanks, that's working for me.

Please also see in SHtml:


  /**
   * Build a JavaScript function that will perform a JSON call based on a value calculated in JavaScript
   *
   * @param jsCalcValue the JavaScript to calculate the value to be sent to the server
   * @param jsContext the context instance that defines JavaScript to be executed on call success or failure
   * @param func the function to call when the data is sent
   *
   * @return the function ID and JavaScript that makes the call
   */
  def jsonCall(jsCalcValue: JsExp, func: Any => JsCmd): (String, JsExp)

You can pass any JavaScript expression that yields a JSON object which is serialized and passed to your function.
 



--
Lift, the simply functional web framework http://liftweb.net
Reply all
Reply to author
Forward
0 new messages