簡體   English   中英

Grails jQuery-ui自動完成

[英]Grails jQuery-ui autocomplete

所以我正在嘗試使用不同的方法在grails中使用自動完成功能,這是到目前為止我所擁有的...

“對象”控制器(是的,事后看來,這是一個非常糟糕的名字):-

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

在頁面的頂部,我得到了:-

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

在主體內,我有一張看起來像簡化表的表格(它是在加載時由多個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>

當我在輸入中輸入ththign時,沒有任何反應,有什么線索嗎? 我什至嘗試將println添加到控制器中只是為了輸出任何內容,並且未注冊該內容……我看不到firebug中發生的任何事情。

我最終回到了使用richui的位置,一旦我解決了有關更改ID和名稱的問題,幾乎可以完成我需要的所有操作。

原始問題在這里

我看到的一個問題是g:createlink使用方式。

應該是這樣的:

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

僅使用g:createLink會將其呈現為字符串。 控制器約定還規定使用camelCase的含義應以小寫字母開頭。

鏈接也可以幫助您使其正常工作:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM