[Lift] Re: Mapper record deletion
> As I move deeper into learning Lift, I now want to start deleting > Mapper records in the ToDo example. Here's how I did it (based on suggestions in this group, I think): bind ( "question", html, "text" -> .., "delete" -> ajaxButton(Text("Remove"), Call("dialog", Str("Do you want to delete the question?")), () => {q.delete_!; S.notice( "Deleted the question!"); reDraw ()}) ) .. and then in the template (default.html) .. function dialog(text, theCall) { if (confirm(text)) theCall(); } -Magnus --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] More compact validation
Hi. In my lift application using Mapper, I'm doing this all the time: object name extends MappedPoliteString(this, 16) { override def validations = Validate.notEmpty(this) _ :: super.validations } where Validate is defined: object Validate { val valid = List[FieldError]() def notEmpty(fi: FieldIdentifier)(field: String) = { if (field.length == 0) List(FieldError(fi, Text("Field cannot be empty"))) else valid } This code works, but is a bit verbose, especially when there are 10 or more strings in a class. I guess I could define a new class MappedPoliteNonEmptyString, but are there other (better) alternatives? -Magnus --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Alternating row colors
To elaborate, I added a $(document).ready function to handle this. However! Some other pages have ajax functionality. When they update html in the page, this html (and the page) will not be 'reprocessed' by JQuery. Can I handle this in a generic manner? -Magnus On May 11, 5:09 pm, Magnus Alvestad wrote: > Ah! Based on Viktors suggestions and some more info at: > > http://15daysofjquery.com/examples/zebra/ > > I was able to write this in a couple of lines of JQuery! > > -Magnus --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Alternating row colors
Ah! Based on Viktors suggestions and some more info at: http://15daysofjquery.com/examples/zebra/ I was able to write this in a couple of lines of JQuery! -Magnus --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Alternating row colors
Thank you for your answers. I'll try to include some more detail because I was not able to apply your suggestions to my code. My template has a section like this: while my snippet looks more or less like this: class T { val questions = "One" :: "Two" :: "Three" :: Nil private def doList()(html:NodeSeq): NodeSeq = { questions.flatMap(q => bind ("question", html, "text" -> Text(q)) } def list(html:NodeSeq) = { bind("question", html, "list" -> doList() ) } } -Magnus --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Alternating row colors
I'm still learning lift (and scala). For my sample application I want to display a table with alternating row colors. I want to put the style in my CSS file and add a classname to every TR in my table to indicate odd and even rows. However, I don't know how to take a value from the snippet binding and assigning it to an attribute in my template file. Can anyone point me in the right direction? -Magnus --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---