简体   繁体   English

Grails jQuery-ui自动完成

[英]Grails jQuery-ui autocomplete

So I'm attempting a different route to using autocomplete within grails, here's what I've got so far... 所以我正在尝试使用不同的方法在grails中使用自动完成功能,这是到目前为止我所拥有的...

"Object" Controller (yeah I know thats a really bad name now in hindsight): - “对象”控制器(是的,事后看来,这是一个非常糟糕的名字):-

def objectFinderAJAX = {
    def objectsFound = Object.withCriteria{
        ilike 'objDesc', '%' + params.term + '%'
    }
    render (objectsFound as JSON)
} 

In the head of the page I've got this: - 在页面的顶部,我得到了:-

$(document).ready(function(){
    $("#eventList > tbody > tr").find('input[type=text]').each(function() {
        $(this).autocomplete({
            source: '<g:createLink controller='Object' action='objectFinderAJAX'/>'
        });
    });  
});     

And within the body I've got a table that looks, in its simplified form, like so (this is constructed with multiple AJAX calls on load) :- 在主体内,我有一张看起来像简化表的表格(它是在加载时由多个AJAX调用构成的):

<table id="eventList">
        <col width="500">
        <col width="750">
            <tr id = 0 class="even" name="main">
                <td colspan="3">
                    <table id = "sub">
                        <tr>
                            <td><b>Action</b></td>
                            <td><select style="width:375px;" name="events[0].id" required="required" id="events[0].id" ><option value="11" >Check a links displayed text</option></select></td>
                            <td>
                                <b>Object</b>
                            </td>
                            <td>
                                <input style="width:500px" id="autoLook[0].id" name="autoLook[0].id" value= "Browser"/>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
</table>

Bot nothing is happening when I type anythign in the input, any clues? 当我在输入中输入ththign时,没有任何反应,有什么线索吗? I even tried adding in a println to the controller just to output anything and its not registering that... I cant see anything happening within firebug. 我什至尝试将println添加到控制器中只是为了输出任何内容,并且未注册该内容……我看不到firebug中发生的任何事情。

I ended up going back to utilising richui which pretty much did everything I needed out of the box once I resolved the issue around changing IDs and names. 我最终回到了使用richui的位置,一旦我解决了有关更改ID和名称的问题,几乎可以完成我需要的所有操作。

Original issue is here . 原始问题在这里

One issue I see is the way g:createlink has been used. 我看到的一个问题是g:createlink使用方式。

It should be like this: 应该是这样的:

${createLink(controller: 'object' , action:'objectFinderAJAX')}

Just using the g:createLink will render it as a string. 仅使用g:createLink会将其呈现为字符串。 Also the controller convention dictates to use camelCase meaning should start with lowercase letter. 控制器约定还规定使用camelCase的含义应以小写字母开头。

this link may also help you to get it work: 链接也可以帮助您使其正常工作:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM