Lift Web : Basics of using snippets for a beginner

Table of contents
Reading Time: 2 minutes

If you are a beginner of using Lift web framework, then it will help you a lot for understanding how to play with views and snippets.

Here, I am explaining some basic use of snippets.
1. Replace id of a html attribute , if class is given.

2. Replace id of a html attribute , if id is given

Use # for id and .(dot) for class
3. Add a style to html element, if class is given

4. Replace content of particular id

5. Replace value of particular element

6. How to use Javascript alert

7. Ajax click event on button.
a) Here “Create” will be text of Button.

b) No button text here

8. Get value of Text box

Here 1st argument will set the text box default value and 2nd argument which is a function will get textbox value and assign it to text variable.

9. Get value of TextArea

Here 1st argument will set the TextArea default value and 2nd argument which is a function will get TextArea value and assign it to text variable.

10. If you want to show any message from snippets then use it as :

Here S.error() is used for displaying error message and S.notice() is used to display notice messgae.
Messages will be displayed where above “div” tag will be defined.

11. Set full html content to given id.

SetHtml() takes 2 arguments. one is id where html content to replace and second is scala NodeSeq.
12. How to write javascript code in snippets :

Whatever we write in between script tag, we can write directly that into JsRaw() method

Written by 

Rishi is a tech enthusiast with having around 10 years of experience who loves to solve complex problems with pure quality. He is a functional programmer and loves to learn new trending technologies. His leadership skill is well prooven and has delivered multiple distributed applications with high scalability and availability by keeping the Reactive principles in mind. He is well versed with Scala, Akka, Akka HTTP, Akka Streams, Java8, Reactive principles, Microservice architecture, Async programming, functional programming, distributed systems, AWS, docker.

1 thought on “Lift Web : Basics of using snippets for a beginner3 min read

Comments are closed.

Discover more from Knoldus Blogs

Subscribe now to keep reading and get access to the full archive.

Continue reading