symfony/symfony-docs — pull request #2158 by WouterJ (2013-01-19 10:01:24+00:00)
Title: [Cookbook/Form] Fixed jQuery bug

| Q | A
| ------------- | ---
| Doc fix? | yes
| New docs? | no
| Applies to | 2.0
| Fixed tickets | #1382

### Description

This PR fixes the old bug while adding new items. If you press the 'add a tag' button 4 times you get the indexes `0, 1, 2, 3`. If you remove 1 and 2, you have the indexes `0, 3`. If you press the 'add a tag' button twice after this, you expect to get `0, 3, 4, 5`, but you got `0, 3, 2, 3`.

This PR saves the index in a `data-index` attribute on the `$collectionHolder`.

### Live examples

Before: http://jsfiddle.net/WouterJ/847Kf/
After: http://jsfiddle.net/WouterJ/847Kf/1/

### Side fixes

This PR also improves the jQuery code by adding support of `e.preventDefault()` for old browsers and by using the `data` method to get `data-*` attributes.

At least, this PR fixes a Sphinx syntax bug (`.. index:` instead of `.. index::`)