SCALA Lift - 访问 AJAX 表单值
我有以下表单:
<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 方法的值是空的。我错过了什么会导致他们丢失?
感谢您提前提供任何帮助:)
I have the following form:
<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>
Which goes to:
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)
}
}
However when I submit the form the values passed to the process method are empty. What am I missing that would cause them to be lost?
Thanks for any help in advance :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我现在无法测试它,但可能是
SHtml.onSubmit
在 Ajax 上下文中不起作用。如果您查看文档,就会发现SHtml.onSubmit
仅在非 Ajax 示例中使用。 Ajax 示例使用SHtml.text
将回调绑定到文本输入字段。I’m not able to test it right now but it could be that
SHtml.onSubmit
does not work in an Ajax context. If you look at the documentation,SHtml.onSubmit
is only used in the non-Ajax example. The Ajax examples useSHtml.text
to bind a callback to the text input fields.