Grails 自动完成与 DependsOn 不起作用

发布于 2024-12-10 00:19:31 字数 708 浏览 2 评论 0原文

我的 .gsp 中有这段代码:

<input id="selection1" type="hidden" name="selection1" value="test"/>
 <gui:autoComplete
  minQueryLength='2'
  queryDelay="0.2"
  id="corso"
  controller="utente"
  action="corsoAutoComplete"
  resultName="corsi"
  dependsOn="selection1"
 />

我使用 Grails-ui 1.2

我的控制器是:

def corsoAutoComplete={
    println params;
    def corso = Corso.findAllByNomeIlike("%${params.query}%",[max:15,cache:true])
    corso = corso.collect{
        [id:it.id, name:it.nome]
        }
    def jsonCorso = [corsi:corso]
    render jsonCorso as JSON        
    }

println params 不返回 id="selecion1" 的输入值,

为什么???

I have this code in my .gsp:

<input id="selection1" type="hidden" name="selection1" value="test"/>
 <gui:autoComplete
  minQueryLength='2'
  queryDelay="0.2"
  id="corso"
  controller="utente"
  action="corsoAutoComplete"
  resultName="corsi"
  dependsOn="selection1"
 />

I use Grails-ui 1.2

My controller is that:

def corsoAutoComplete={
    println params;
    def corso = Corso.findAllByNomeIlike("%${params.query}%",[max:15,cache:true])
    corso = corso.collect{
        [id:it.id, name:it.nome]
        }
    def jsonCorso = [corsi:corso]
    render jsonCorso as JSON        
    }

println params doesn't return the value of input with id="selecion1"

why???

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

意中人 2024-12-17 00:19:31

1) 尽管插件页面上有示例,但我不确定 Grails UI 自动完成 dependsOn 可以是另一个自动完成控件,因为它需要订阅“itemselect” “依赖”控件中的事件(查看 InputTagLib.groovy 的插件源)

2)如果将“依赖”控件更改为另一个自动完成功能(可以使它们像普通 HTML 一样工作) selects),请尝试对 dependsOn 属性使用以下语法:

dependsOn="[label:'(control name)',value:'(desired param name)',useId:(true to use select id value)]"

另请查看 grails ui 演示,其中包含每个组件的工作示例代码:
http://code.google.com/p/guidemo/

1) Despite the example on the plugin's page I'm not sure that the Grails UI autocomplete dependsOn can be anything but another autocomplete control because it needs to subscribe to an "itemselect" event in the "depended on" control (look at the plugin source for InputTagLib.groovy)

2) If you change the "depended on" control to another autocomplete (they can be made to work like normal HTML selects), try using the following syntax for the dependsOn property:

dependsOn="[label:'(control name)',value:'(desired param name)',useId:(true to use select id value)]"

Also have a look at the grails ui demo that has working sample code for each of the components:
http://code.google.com/p/guidemo/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文