Nested ids in Lift:Msg

28 views
Skip to first unread message

JMo

unread,
Dec 2, 2011, 6:12:16 PM12/2/11
to Lift
Hello everyone,
Please bear with me as I'm pretty new to this.
I've been having some trouble with my id specific error messages on my
ajax form.
They are showing up in the right places, but the error's span nests
another error span with the same id which has another span in it with
my error class, like so:

<span id="error_pw1">
<span id="error_pw1">
<span class="error">password must be at least 6 characters</
span>
</span>
</span>


I really appreciate any help into this mystery wrapped in a span
surrounded by an enigma.


form template markup excerpt:

<form id="reg_form" class="lift:Registration.form" method="post" >
<input type="password" id="pw1"><span class="lift:msg?
id=error_pw1&errorClass=error"></span>
</form>

snippet code excerpt:

def form = {
def processReg() {
var errors = false
if (pw1.length < 6) {
S.error("error_pw1", "password must be at least 6
characters")
errors = true
}
}

if (!errors) {
// submit form, etc.,
}

"#pw1" #> SHtml.password(pw1, pw1 = _) &
"type=submit" #> SHtml.ajaxSubmit("Submit", processReg) andThen
SHtml.makeFormsAjax

}


Thank you...

Tim Nelson

unread,
Dec 2, 2011, 9:24:01 PM12/2/11
to lif...@googlegroups.com
Hi JMo,

I actually ran into this same problem myself today.

I created a ticket [1] and have a solution on this branch [2], but we're in code slush so I'm not sure when this will get pushed to master.

For now you could override LiftRules.noticesToJsCmd and modify the call to Msg.renderIdMsgs, or you could just write your own snippet to handle it the way you want.

Tim

Reply all
Reply to author
Forward
0 new messages