Recommended style for Nodeseq as a param for ajaxButton.

Visto 27 veces
Saltar al primer mensaje no leído

uthang

no leída,
15 feb 2015, 23:10:5015/2/15
a lif...@googlegroups.com
Hello all,
In summary, my goal is to have an ajax button getting data from the server and updating a list on html.
This snippet below works fine, but I would like to know a recommended way in this case, constructing Nodeseq and send to ajaxButton.

Html snippet:
<ul id="my_list">
<li>Insert here</li>
</ul>

Scala snippet:
def renderMyList = {
val cssSel = "li *" #> Db.getMyList
cssSel(<li></li>)
}
 
def doAJAX() = {
"type=submit" #>
SHtml.ajaxButton(
"AJAX button",
() => JqJsCmds.AppendHtml("my_list", renderMyList)) andThen SHtml.makeFormsAjax
}

Thank you. 

Diego Medina

no leída,
17 feb 2015, 13:49:3817/2/15
a Lift
What you are doing is fine, another option is to use idMemoize http://lift.la/blog/shtmlidmemoize-simple-ajax-updating
and if you are into using more client side libraries, like http://knockoutjs.com/ , then you could simply send json data with the rows and let knockout take care of the UI

For the last option, maybe these posts will help:

http://blog.fmpwizard.com/blog/comparing-comet-javascript-knockoutjs
https://fmpwizard.telegr.am/blog/comparing-comet-javascript-knockoutjs-part-ii
https://fmpwizard.telegr.am/blog/comparing-comet-javascript-angularjs-part-iii

Thanks

Diego




--
--
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

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Diego Medina
Lift/Scala consultant
di...@fmpwizard.com
http://fmpwizard.telegr.am

uthang

no leída,
18 feb 2015, 2:02:4318/2/15
a lif...@googlegroups.com
Thank you for the links, those should be parts of Lift tutorial. Your blog is excellent.

Could you correct me on how my approach works? Here is my guess.
- Retrieve data and build up a chunk of html from that data on server side and send it to client for another processing; appendHtml, SetHtml, etc.

Benefit of KO approach
- Less overhead on the server and network.
- Easier to work with json on client side, especially with more complex html structure.

Thank you.

Diego Medina

no leída,
18 feb 2015, 2:24:5018/2/15
a Lift
see inline:

On Wed, Feb 18, 2015 at 2:02 AM, uthang <k9a...@gmail.com> wrote:
Thank you for the links, those should be parts of Lift tutorial. Your blog is excellent.


Thanks! I'll think about ways to expose them more.
 
Could you correct me on how my approach works? Here is my guess.
- Retrieve data and build up a chunk of html from that data on server side and send it to client for another processing; appendHtml, SetHtml, etc.


corrent

 
Benefit of KO approach
- Less overhead on the server and network.
- Easier to work with json on client side, especially with more complex html structure.


correct


My favorite way to write an app is, I do the initial render of the page server side using snippet like you see most Lift apps do, and when I have an ajax button or comet action, then I simply send json from the server and use some client side library to do the rendering.
Something I don't generally like is what a lot of people do these days with single page apps, while the original idea sounded good, what I see in practice is that your users end up with a page that doesn't have content for x number of milliseconds (enough to notice) and then the content starts showing up.

Thanks and all the best  on your Lift app(s)!

Diego

uthang

no leída,
18 feb 2015, 10:16:4718/2/15
a lif...@googlegroups.com
Thank you. I appreciate choices of rendering UI.
If only json was not an issue, just Lift's approach would be elegant ajax style.

Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos