Reputation: 15335
Following this question: Modify attribute of element, I would like to know if there is a clean way to remove an attribute in Lift. For now I directly run the javascript command:
Run("document.getElementById(\"elem_id\").removeAttribute(\"disabled\", 0);")
Is there a better way of doing this?
For example, to edit an attribute, it is possible to use the following command:
(JqId("elem_id")~> JqAttr("disabled", "disabled")).cmd
Upvotes: 0
Views: 183
Reputation: 7848
I don't see a built in removeAttribute option in JqJE, but you should be able to roll your own. If you define something like this:
case class RemoveAttr(key: String) extends JsExp with
JsMember with JQueryRight with JQueryLeft {
def toJsCmd = "removeAttr(" + key.encJs + ")"
}
and then call like:
JqId("elem_id")~> RemoveAttr("disabled")
I haven't tested it, but I think it should accomplish what you are looking to do.
You can find the source for JqJE here: https://github.com/lift/framework/blob/master/web/webkit/src/main/scala/net/liftweb/http/js/jquery/JqJsCmds.scala#L168
Upvotes: 1