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
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.
Whatever we write in between script tag, we can write directly that into JsRaw() method