Grails的richui自动完成的文本框克隆 [英] Grails richui autocomplete for cloned textbox

查看:159
本文介绍了Grails的richui自动完成的文本框克隆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是用我的应用程序 Grails的richui自动完成字段。
它工作正常的我的静态文本框,但是当我克隆此功能不是为了克隆工作文本框的文本框中,它甚至没有显示出错误。

I am using grails richui autocomplete field in my app. It works fine for my static textbox but when I clone the textbox this feature is not working for the cloned textboxes and it shows no error even.

如何解决这个任何想法

下面是我的code:

<resource:autoComplete skin="default" />

在顶部

<richui:autoComplete name="filterLocation1" id="filterLocation1" delimChar=";"  class="location_txtbox" action="${createLinkTo('dir': 'abc/yyy')}" style="margin-left:5px;"/>

这是我的自动完成字段

和我克隆这样的

var counter = 1;
$("#addRow").click(function() {
counter++;
var cln = $('#static_table tbody>tr:last').clone(true);
cln.find("[id^='filterLocation']").each(function(i, val) {
    val.id = val.id.match(/^([^0-9]+)[0-9]*$/)[1] + "" + counter;
});

return false;
});

我克隆整个行,做一些隐藏/显示操作和递增的ID。

I clone the entire row, do some hide/show operations and increment the ids.

推荐答案

在克隆 TR 将其克隆的所有内容,它包括 JavaScript的由插件创建。该克隆脚本使用文本字段中的 ID 使其自动完成。这 ID 和文本字段是必须的改变,使克隆自动完成的作品。

When you clone the tr it clone all the content, it include the javascript create by the plugin. This cloned script uses the id of the text field to make it auto complete. This id and text field is required to change to make cloned autocomplete works.

我用下面的脚本来更改标识:

I use following script to change that ids:

<script type="text/javascript">
    var counter = 1;
    function asd() {
        var cloneContent = "<tr>" + $("#firstTrToClone").html().replace(/giveAUniqueId/g, "giveAUniqueId" + counter++) + "</tr>";
        $("#tableId").append(cloneContent);
    }
</script>

以下是我完整的工作页面:

<!DOCTYPE html>
<html>
<head>
<resource:autoComplete skin="default"/>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
    var counter = 1;
    function asd() {
        var cloneContent = "<tr>" + $("#firstTrToClone").html().replace(/giveAUniqueId/g, "giveAUniqueId" + counter++) + "</tr>";
        $("#tableId").append(cloneContent);
    }
</script>
</head>

<body>
<g:form>
<table id="tableId">
    <tr id="firstTrToClone">
        <td>
            <richui:autoComplete name="name" id="giveAUniqueId" action="${createLinkTo('dir': 'oauthCallBack/test')}"/>
        </td>
    </tr>
</table>
</g:form>

<button onclick="asd()">Clone</button>

</body>
</html>

试试吧..,。

这篇关于Grails的richui自动完成的文本框克隆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆