In the previous recipe, we learned how to show data that should be unique using a CSS selector and the id
attribute of HTML tags. However, there are a lot of times when we need to show collections of data, such as the names of students in a given classroom, the list of items in a shopping cart, or a list of whatever else you can think of.
This is exactly what we will learn how to do in this recipe.
You can use the code from the examples we used in the previous recipe or you can start a new project.
A HTML list can be created by following these steps:
Add the following section in the
index.html
file:<div data-lift="Animals.list"> <ul> <li><span class="name"></span> - <span class="sname"></span></li> </ul> </div>
Create a file called
Animals.scala
in thesnippets
folder with the following code:import net.liftweb.util.BindHelpers._ import xml.Text object Animals...