Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have not much idea about your gsp page but I tried it on my side:</p> <p><strong>My gsp:</strong></p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;resource:autoComplete skin="default"/&gt; &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; var counter = ${list.size()}; function asd() { jQuery.ajax({ url: " ${createLink(controller: 'oauthCallBack', action: 'testAuto')}", data: "idx=" + counter++, success: function (data) { jQuery("#tableId").append("&lt;tr&gt;&lt;td&gt;" + data + "&lt;/td&gt;&lt;/tr&gt;"); } }); } function updateHiddenInput(id, tg) { jQuery(tg).val(id); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;g:form&gt; &lt;table id="tableId"&gt; &lt;g:each in="${list}" var="vr" status="idx"&gt; &lt;tr&gt; &lt;td&gt; &lt;richui:autoComplete name="name" id="uniqueId${idx}" action="${createLinkTo('dir': 'oauthCallBack/test')}" onItemSelect="updateHiddenInput(id, someId${idx})"/&gt; &lt;g:hiddenField name="someName" id="someId${idx}" value=""/&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/g:each&gt; &lt;/table&gt; &lt;/g:form&gt; &lt;button onclick="asd()"&gt;Add&lt;/button&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><strong>My action:</strong></p> <pre><code>def testAuto() { render template: 'addNew', model: [idx: params.idx] } </code></pre> <p><strong>My template(addNew):</strong></p> <pre><code>&lt;richui:autoComplete name="name" id="uniqueId${idx}" action="${createLinkTo('dir': 'oauthCallBack/test')}" onItemSelect="updateHiddenInput(id, someId${idx})"/&gt; &lt;g:hiddenField name="someName" id="someId${idx}" value=""/&gt; </code></pre> <p>Try this..,.</p> <hr> <hr> <p><strong>EDIT.....................................................................................</strong></p> <p>I supposed that you have successfully updated all the input field names. Then you can edit hidden field like:</p> <p><strong>View:</strong></p> <pre><code>&lt;tr class="dummyClass"&gt; &lt;td&gt; &lt;richui:autoComplete name="name[${idx}]" id="uniqueId[${idx}]" action="${createLinkTo('dir': 'oauthCallBack/test')}" onItemSelect="updateHiddenInput(id, this)"/&gt; &lt;g:hiddenField name="someName[${idx}]" id="someId[${idx}]" value=""/&gt; &lt;/td&gt; &lt;/tr&gt; </code></pre> <p><strong>jQuery:</strong></p> <pre><code>function updateHiddenInput(id, tg) { jQuery(tg._elTextbox).closest("tr.dummyClass").find("input[type=hidden]").val(id); } </code></pre> <hr> <hr> <p><strong>EDIT.....................................................................................</strong></p> <p>Why you need to change the 'id'? Changing name is sufficient to send values in order. And you can update the hidden field without id as above edit.</p> <p>If you still need to change the id then you can change it by cloning the tr and then use regex. See <a href="https://stackoverflow.com/questions/15608225/grails-richui-autocomplete-for-cloned-textbox/19937143#19937143">this answer</a> for full working example. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload