Lift:如何将超链接绑定到服务器端方法
我是 Lift 新手,我想使用超链接而不是提交按钮。我可以使用 CSS 选择器通过服务器端方法绑定我的提交按钮。例如:
def render = {
// define some variables to put our values into
// process the form
def process() {
do something....
}
}
"type=submit" #> SHtml.onSubmitUnit(process)
}
我想使用超链接来提交表单而不是提交按钮。如何使用 process()(服务器端)方法绑定超链接。
谢谢, 普内特
I am new to Lift, I want to use hyperlink instead of submit button. I am able to bind my submit button with a server-side method use CSS Selector. for example:
def render = {
// define some variables to put our values into
// process the form
def process() {
do something....
}
}
"type=submit" #> SHtml.onSubmitUnit(process)
}
I want to use hyperlink to submit my form instead of submit button. How can I bind hyperlink with process()(server-side) method.
Thanks,
Puneet
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这种情况下,您可能希望使用 SHtml.ajaxCall 并提供表单信息作为 JsonContext(即不与 CSS 选择器绑定):
或者您可以使用 SHtml.a:
如果失败,您应该查看 SHtml 中的可用方法(jsonForm将是另一个值得一看的)并看看哪一个最适合您的用例。我鼓励您阅读《Lift in Action》的副本,其中讨论了函数绑定的工作原理,因为我认为您误解了它与请求/响应周期的关系。
In this instance you would probably want to use SHtml.ajaxCall and supply the form information as the JsonContext (i.e. not bound with CSS selectors):
Alternativly you could use SHtml.a:
Failing that you should look at the available methods in SHtml (jsonForm would be another one to look at) and see which one best fits your use case. I would encourage you to pick up a copy of Lift in Action which discusses how the function binding works, as I think you have miss-understood it in relation to the request/response cycle.