ok, I have a button on a page so that the user can create a 'note'
MySnippet:
private def addNoteForm(deal:Deal) = {
SHtml.ajaxButton("New Note",
() => S.runTemplate("templates-hidden" ::
"note_create" :: Nil).
map(ns => ModalDialog(ns)) openOr
Alert("Couldn't find note_create template"))
}
The note_create template looks like this:
<lift:snippet type="MySnippet:createNote" form="post">
<p>
Subject: <note:subject/>
</p>
....
<note:submit/>
</lift:snippet>
and the createNote method:
def createNote(xhtml:NodeSeq):NodeSeq = {
val note = new Note...
def saveNote = note.validate match {
case Nil => println("saving");note.save; initialiseNotes(deal)
case x => SetHtml("errors", x.map((e:FieldError) => <li>{e.msg}</
li>))
}
bind("note", xhtml,
"subject" -> text("", (s) =>
{println(s);note.subject(s)}),
"message" -> text("", note.message(_)),
"submit" -> submit("Save", () => saveNote & Unblock)
)
}
When the form is submitted, the correct note is created but after the
dialog is closed I get a page of javascript.
If I use an ajaxSubmit("Save", ()=>... the dialog closes but the
saveNote function is called before the functions to update the
'subject' and 'message' fields, so my note is empty.