how to read some data from html page

190 views
Skip to first unread message

Lex

unread,
Apr 7, 2011, 6:29:06 AM4/7/11
to Lift
How can I read some data from html page into the Lift variable?
Lets say I have an javascript editor on my page and I want to grab
it's value via 'id' or javascript function like 'editor.getData()'.
And I need to save to local variable cos it is inside the ajax form.
Or how should I do this?

Stefan Langer

unread,
Apr 7, 2011, 7:13:50 AM4/7/11
to lif...@googlegroups.com, Lex
Json and stringify comes to mind.

2011/4/7 Lex <lexr...@gmail.com>:

> --
> You received this message because you are subscribed to the Google Groups "Lift" group.
> 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.
>
>

David Pollak

unread,
Apr 7, 2011, 12:09:10 PM4/7/11
to lif...@googlegroups.com
In SHtml:

  /**
   * Build a JavaScript function that will perform an AJAX call based on a value calculated in JavaScript
   *
   * @param jsCalcValue the JavaScript that will be executed on the client to calculate the value to be sent to the server
   * @param func the function to call when the data is sent
   *
   * @return the function ID and JavaScript that makes the call
   */
  def ajaxCall(jsCalcValue: JsExp, func: String => JsCmd): (String, JsExp) =

  /**
   * 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) =

Either of those methods will give you a JsExp which is a JavaScript Expression.  Invoke the JavaScript expression in the browser and the call will be made to the server with the result of the jsCalcValue which calculates the value to send to the server.


--
You received this message because you are subscribed to the Google Groups "Lift" group.
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.




--
Lift, the simply functional web framework http://liftweb.net

Lex

unread,
Apr 8, 2011, 4:11:51 AM4/8/11
to Lift
Seems like ajaxCall is what I need.
This code works for me:

"#ajaxSubmit" #> SHtml.ajaxSubmit("Save",process _) &
"#testSpan [onclick]" #>
SHtml.ajaxCall(JE.JsRaw("ckeditor.getData()"), { x => value = x;
println("======>"+x)})

But how can I execute ajaxCall in ajaxSubmit?

On Apr 7, 11:09 pm, David Pollak <feeder.of.the.be...@gmail.com>
wrote:
> Beginning Scalahttp://www.apress.com/book/view/1430219890

Lex

unread,
Apr 11, 2011, 3:33:51 AM4/11/11
to Lift
Anyone?
How can I execute "ajaxCall" before the form submitting?
If I'm using "ajaxSubmit" to submit the form.

David Pollak

unread,
May 20, 2011, 7:16:32 PM5/20/11
to lif...@googlegroups.com
On Fri, Apr 8, 2011 at 1:11 AM, Lex <lexr...@gmail.com> wrote:
Seems like ajaxCall is what I need.
This code works for me:

"#ajaxSubmit" #> SHtml.ajaxSubmit("Save",process _) &
"#testSpan [onclick]" #>
SHtml.ajaxCall(JE.JsRaw("ckeditor.getData()"), { x => value = x;
println("======>"+x)})

But how can I execute ajaxCall in ajaxSubmit?


Just change to:

"#ajaxSubmit [onclick]" #> SHtml.ajaxCall(....)
 



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