AJAX is an approach for building dynamic web content on the client side . In Liftweb , we can implement this approach either by AJAX or by Comet . Comet is like AJAX , except in opposite direction .
AJAX model increases the richness of the User Experience for a single client at a time, Comet can do the same for multiple users.
First thing , I want to point out here is that AJAX generators take callback methods just like regular element generators. The only Difference is that when we call SHtml generator , it always returns SHtml.any . On the other way , when we call AJAX , it must returns a net.liftweb.http.js.JsCmd. The reason is that the return from the callback is itself a client-side callback that can be used to update the client content.
Let’s have a look at some AJAX generators :
1) ajaxButton : Renders a button that will submit an AJAX request to server .
2) ajaxText : Renders an input text element that will send an AJAX request on blur.
This is very useful when you want to get text box value , once user hits enter key .
In jsCalcValue , you can get only one html element value by id using JE.ValById(“test”) and pass this value to java script function .
4)ajaxInvoke: Similar to ajaxCall but there is no value to be computed and sent to the server
5)ajaxRadio: Renders a radio element then sends an AJAX call when the value changes
6)ajaxSelect: Renders a select element then sends an AJAX call when the value changes
7)ajaxCheckbox: Renders a checkbox element that when clicked will send an AJAX call
8)ajaxForm: Wraps a NodeSeq that represents the form’s content and makes an AJAX call when the form is submitted.
1 thought on “Play With Liftweb’s AJAX Generators using Scala3 min read”
Reblogged this on Agile Mobile Developer.
Comments are closed.