Skip to main content

Search and Top Navigation

#5866 closed bug (notabug)

Opened July 28, 2010 08:48PM UTC

Closed July 28, 2010 09:15PM UTC

Last modified October 11, 2012 09:15PM UTC

Problem With Autocomplete Of Cloned Element

Reported by: john123 Owned by:
Priority: minor Milestone:
Component: ui.autocomplete Version: 1.8.2
Keywords: Cc:
Blocked by: Blocking:
Description

Hi,

It appears that autocomplete cannot be overridden on a cloned element. See the simple example below:

<html>

<head>

<link rel="stylesheet" type="text/css" media="all" href="../jq/css/ui-lightness/jquery-ui-1.8.2.custom.css" />

<script type="text/javascript" src="../jq/js/jquery-1.4.2.min.js"></script>

<script type="text/javascript" src="../jq/js/jquery-ui-1.8.2.custom.min.js"></script>

<link type="text/css" href="../jq/development-bundle/themes/base/jquery.ui.all.css" rel="stylesheet" />

<script type="text/javascript">

$(document).ready(function() {

jQuery(function() {

$("input[name*=name]").each(function() {

$(this).autocomplete({

source: ["Fred", "Harold"]

});

});

$('.plus').bind('click', addRow);

});

});

function addRow(e) {

var tblRow = $(this).parents("tr");

var newTblRow = tblRow.clone(true);

$(this).parents("span").text("");

newTblRow.insertAfter(tblRow);

newTblRow.children().each(function() {

$(this).children("input").each(function() {

var theName = $(this).attr("name");

var splitName = theName.split("_");

var varName = splitName[0];

var idx = splitName[1]*1;

var newIdx = idx+1;

var newName = varName + "_" + newIdx;

$(this).attr("name", newName);

$(this).attr("value", "");

if (theName.indexOf('name') != -1) {

$(this).autocomplete("destroy");

$(this).autocomplete({

source: ["Jim", "Lou"]

});

}

});

});

}

</script>

</head>

<body>

<form name=theForm>

<center>

<table>

<tr>

<th></th>

<th>Name</th>

<th>Age</th>

</tr>

<tr>

<td><span class=plus>+</span></td>

<td><input type=text name=name size=17></input></td>

<td><input type=text name=age size=4></input></td>

</tr>

</table>

</form>

</body>

</html>

Attachments (0)
Change History (2)

Changed July 28, 2010 09:15PM UTC by scottgonzalez comment:1

resolution: → invalid
status: newclosed

We don't support cloning plugins.

Changed October 11, 2012 09:15PM UTC by scottgonzalez comment:2

milestone: TBD

Milestone TBD deleted