|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
How do you set disabled/readonly attributes from a snippet?I found this answer on nabble but it's regarding setting the values client side. I want to set them in the snippet, depending on data.
This doesn't work, but will give you a better idea of what I'm trying to do: def bindPerson(xhtml: NodeSeq, action: () => Unit, submitButtonName: String, disableAll: boolean): NodeSeq = { // Hold a val here so that the "id" closure holds it when we re-enter this method val currentId = person.id val disableString :String = disableAll match { case true => "disabled" case false => "" } bind("person", xhtml, "id" -> SHtml.hidden(() => person.id = currentId), // "version" -> SHtml.hidden(() => person.version), "firstName" -> SHtml.text(person.firstName, person.firstName = _, "id" -> "firstName", "disabled" -> disableString), "middleName" -> SHtml.text(person.middleName, person.middleName = _, "id" -> "middleName", "disabled" -> disableString), "lastName" -> SHtml.text(person.lastName, person.lastName = _, "id" -> "lastName", "disabled" -> disableString), "submit" -> SHtml.submit(?(submitButtonName), action)) } -- James A Barrows --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@... To unsubscribe from this group, send email to liftweb+unsubscribe@... For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: How do you set disabled/readonly attributes from a snippet?Use None (Option) or Empty (Box) as the value of the attribute -- this will cause the pairToUnprefixed implicit that is being used inside SHtml to not generate an attribute. e.g.: val disableAttr: Box[String] = if (disableAll) Full("disabled") else Empty bind("person", xhtml, ... "firstName" -> SHtml.text(person.firstName, person.firstName = _, "id" -> "firstName", "disabled" -> disableAttr), ...) -Ross On Nov 9, 2009, at 6:51 PM, Jim Barrows wrote: > I found this answer on nabble but it's regarding setting the values > client side. I want to set them in the snippet, depending on data. > This doesn't work, but will give you a better idea of what I'm > trying to do: > def bindPerson(xhtml: NodeSeq, action: () => Unit, > submitButtonName: String, disableAll: boolean): NodeSeq = { > // Hold a val here so that the "id" closure holds it when we re- > enter this method > val currentId = person.id > val disableString :String = disableAll match { > case true => "disabled" > case false => "" > } > bind("person", xhtml, > "id" -> SHtml.hidden(() => person.id = currentId), > // "version" -> SHtml.hidden(() => person.version), > "firstName" -> SHtml.text(person.firstName, person.firstName = > _, "id" -> "firstName", "disabled" -> disableString), > "middleName" -> SHtml.text(person.middleName, > person.middleName = _, "id" -> "middleName", "disabled" -> > disableString), > "lastName" -> SHtml.text(person.lastName, person.lastName = _, > "id" -> "lastName", "disabled" -> disableString), > "submit" -> SHtml.submit(?(submitButtonName), action)) > } > > -- > James A Barrows > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@... To unsubscribe from this group, send email to liftweb+unsubscribe@... For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: How do you set disabled/readonly attributes from a snippet?I'm importing HttpHelpers, and the implicit is not there.
Did this change for M7? On Mon, Nov 9, 2009 at 6:41 PM, Ross Mellgren <dridus@...> wrote:
-- James A Barrows --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@... To unsubscribe from this group, send email to liftweb+unsubscribe@... For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: How do you set disabled/readonly attributes from a snippet?On Thu, Nov 12, 2009 at 11:49 AM, Jim Barrows <jim.barrows@...> wrote: I'm importing HttpHelpers, and the implicit is not there. I think what you want is: "firstName" -> (SHtml.text(person.firstName, person.firstName = _) % ("id" -> "firstName") % ("disabled" -> disabledAttr))
-- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Surf the harmonics --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@... To unsubscribe from this group, send email to liftweb+unsubscribe@... For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: How do you set disabled/readonly attributes from a snippet?Oh I didn't mean that you need to import the implicit, just that inside SHtml, the implicit called pairToUnprefixed is being called.
David's solution is correct using Box like I exampled. I didn't check the type signature for SHtml.text, so didn't realize it only took (String, String), not (String, Any) like pairToUnprefixed that it's calling under the covers does -- my apologies :-/ -Ross On Nov 12, 2009, at 2:49 PM, Jim Barrows wrote: I'm importing HttpHelpers, and the implicit is not there. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@... To unsubscribe from this group, send email to liftweb+unsubscribe@... For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~--- |
| Free embeddable forum powered by Nabble | Forum Help |