我有以下表格:
<form class="lift:form.ajax">
<div class="lift:StreamInput">
<input type="hidden" name="path" value="test" />
<input type="hidden" name="user" value="james" />
<input type="hidden" name="level" value="_1" />
<input type="hidden" name="room" value="demo" />
<input type="hidden" name="hidden" value="true" />
</div>
<input type="submit" value="" />
</form>
其中:
object StreamInput {
def render = {
var path = ""
var user = ""
var level = ""
var room = ""
def process(): JsCmd = {
val message = comet.StreamItem(user, path, level, room)
StreamServer ! message
}
"name=path" #> SHtml.onSubmit(path = _) &
"name=user" #> SHtml.onSubmit(user = _) &
"name=level" #> SHtml.onSubmit(level = _) &
"name=room" #> SHtml.onSubmit(room = _) &
"name=hidden" #> SHtml.hidden(process)
}
}
但是,当我提交表单时,传递给process方法的值为空。我错过了什么会导致他们迷失?
感谢您提前提供任何帮助:)
答案 0 :(得分:1)
我现在无法测试它,但可能是SHtml.onSubmit
在Ajax上下文中不起作用。如果查看文档,SHtml.onSubmit
仅用于非Ajax示例。 Ajax示例使用SHtml.text
将回调绑定到文本输入字段。