Permalink
Browse files

* Now the button addes a <p> tag to the end of the table, just to sho…

…w how to get more rows in there.
  • Loading branch information...
1 parent 470320d commit 3240e99b4f589b1b83800909259467e3605e578a @fmpwizard committed Apr 13, 2012
@@ -2,7 +2,7 @@ package com.ciriscr.lazyload.snippet
import net.liftweb.util.Helpers._
import net.liftweb.http.{SHtml, S}
-import net.liftweb.http.js.JsCmds
+import net.liftweb.http.js._
class Test{
@@ -14,16 +14,16 @@ class Test{
private def nextPage: List[String] = this.objects.drop(this.actual).take(this.itemsPerLoad)
def render = {
- "#elementsTable *" #> (S.eagerEval andThen
+ "#elementsTable" #> (S.eagerEval andThen
"@element *" #> nextPage.map{ elem =>
"@number *" #> elem
}
- ) & "button [onclick]" #> SHtml.ajaxInvoke{ () =>
+ &
+ "#button [onclick]" #> SHtml.ajaxInvoke{ () =>
this.actual += this.itemsPerLoad
- //Add the new elements to the page
- //HELP HERE :D
- JsCmds.Alert("See the code")
- }
+ //Change this js to create a new table or rows, this isn't legal html now, but you get the idea :)
+ JsCmds.Run("""$("#table1").append("<p>""" + this.actual + """</p>")""")
+ })
} //render
} //Test
@@ -7,8 +7,8 @@
<div id="cuerpoPrincipal" class="lift:surround?with=principal;at=contenidoPrincipal">
<div id="elementsTable" class="lift:Test">
<div class="lift:embed?what=templates-hidden/objects"></div>
- <button>Load more</button>
+ <button id="button">Load more</button>
</div>
</div>
</body>
-</html>
+</html>
@@ -1,4 +1,4 @@
-<table>
+<table id="table1">
<thead>
<tr>
<th>Element</th>
@@ -9,4 +9,4 @@
<td name="number">####</td>
</tr>
</tbody>
-</table>
+</table>

0 comments on commit 3240e99

Please sign in to comment.