使用Playframework Scala @select模板 - onchange事件 [英] Using the Playframework Scala @select template - onchange event
问题描述
我用Scala使用playframework 2.0,并且我在使用@select模板时遇到了很多问题。
所以我有一个@select字段作为表单的一部分(表单在这里不应该很有趣):
<$ c
表单(< select 1的变量>),
options = options(<返回列表的函数的调用),
'_default - >--- stupid select templates ---,
'_error - > Form.globalError
)
现在我有另一个选择。
这个重要的是 - 我想从一个函数中填充它,它获取第一个@select的实际值作为参数。
@select(
Form(<变量的其他名称>),
options =选项(<函数(<选择1的变量>)>),
'_default - > - 愚蠢的选择模板---,
'_error - > globalError
)
所以我实际需要的是某种onchangeenvent @选择字段。
另一个问题是,playframework无法读取@select的_default值(当我设置一个默认值并尝试在Form中使用它时,它会被计为None)
注意:这两个@selects都在同一个html网站上,并且都属于同一个表单
有人知道解决方法这里?或可能的例子?
@select(editForm(owner.id),options( (id) - >owner,'class - >input-xlarge,'_label - > Messages(owner),_default - > Messages(make.choice) ,'showConstraints - > true,'_help - >)
但我不认为可以从服务器端模板获得 onchange
。你需要用javascript / jQuery来做到这一点。
I am using the playframework 2.0 with scala and I am facing many problem with the @select template. So what I have is a @select field as part of a Form (the Form shouldn't be interesting here):
@select(
Form("<variable of select 1>"),
options = options(<call of function which returns a list>),
'_default -> "--- stupid select templates ---",
'_error -> Form.globalError
)
now i have another select. Important about this one is - I want to fill it from a function, which gets the actual value of the first @select as parameter.
@select(
Form("<other name of variable>"),
options = options(<function(<variable of select 1>)>),
'_default -> "--- stupid select templates ---",
'_error -> Form.globalError
)
So what i actually need is some kind of "onchange" envent for the @select fields. Another problem is, that the playframework can't read the "'_default" value of the @select (when I set a default value and try to use it in a Form, it gets counted as None)
NOTE: both @selects are on the same html site and both belong to the same form
Does someone know a workaround here? or possible examples?
One example where the default
works for me, also if owner is filled the owner will be visible instead of default value.
@select(editForm("owner.id"),options(Task.owners), 'id -> "owner", 'class -> "input-xlarge", '_label -> Messages("owner"), '_default -> Messages("make.choice"), 'showConstraints -> true, '_help -> "")
But I do not think that onchange
is possible from server side templates. You will need to do this with javascript / jQuery.
这篇关于使用Playframework Scala @select模板 - onchange事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!