Ticket #229 (closed defect: fixed)
collection-control "index already in use" problem
| Reported by: | sdm | Owned by: | mpo |
|---|---|---|---|
| Priority: | critical | Milestone: | 0.4 |
| Component: | modules/kauri-forms | Version: | trunk |
| Keywords: | Cc: |
Description
When myForm.setWireValue(...) is called several times on a form which contains a collection-control, the function crashes with the following error:
uncaught exception: [ControlElements#addElementIndex?] index already in use: /tblMyCollectionTable/rid-2256/id#input
An example of when this problem occurs:
A collection-control in a form shows some data, and below the form there's a button which sends an AJAX call to get the data sorted. The result of the AJAX call is the sorted data, which is then bound to the collection-control using myForm.setWireValue(data);
When this sort button is clicked a few times, the problem will suddenly occur and the collection-control will stop adding childrows.
The problem is resolved when clearElementIndex() is called on the form before setWireValue:
myForm.clearElementIndex();
myForm.setWireValue(data);
This problem appears in IE, Firefox and Chrome (I haven't tested in any other browsers).
The random we use for the unique row-id is clearly not 'big' enough for this use case.
In stead of clearing the element-index of the complete form however, we should investigate into clearing only the rows of the collection being changed.