jquery.collection.js
function (collection, settings, elements, element, index) {
            if (elements.length > settings.min && trueOrUndefined(settings.before_remove(collection, element))) {
                var deletion = function () {
                    var toDelete = element;
                    if (!settings.preserve_names) {
                        elements = shiftElementsUp(collection, elements, settings, index);
                        toDelete = elements.last();
                    }
                    var backup = toDelete.clone({withDataAndEvents: true}).show();
                    toDelete.remove();
                    if (!trueOrUndefined(settings.after_remove(collection, backup))) {
                        var elementsParent = $(settings.elements_parent_selector);
                        elementsParent.find('> .' + settings.prefix + '-tmp').before(backup);
                        elements = collection.find(settings.elements_selector);
                        elements = shiftElementsDown(collection, elements, settings, index - 1);
                    }
                    if (settings.position_field_selector) {
                        doRewritePositions(settings, elements);
                    }
                };
                if (settings.fade_out) {
                    element.fadeOut('fast', function () {
                        deletion();
                    });
                } else {
                    deletion();
                }
            }

            return elements;
        }
function (collection, settings, elements, element, index) {
            if (elements.length > settings.min && trueOrUndefined(settings.before_remove(collection, element))) {
                var deletion = function () {
                    var toDelete = element;
                    if (!settings.preserve_names) {
                        elements = shiftElementsUp(collection, elements, settings, index);
                        toDelete = elements.last();
                    }
                    var backup = toDelete.clone({withDataAndEvents: true}).show();
                    toDelete.remove();
                    if (!trueOrUndefined(settings.after_remove(collection, backup))) {
                        var elementsParent = $(settings.elements_parent_selector);
                        elementsParent.find('> .' + settings.prefix + '-tmp').before(backup);
                        elements = collection.find(settings.elements_selector);
                        elements = shiftElementsDown(collection, elements, settings, index - 1);
                    }
                    if (settings.position_field_selector) {
                        doRewritePositions(settings, elements);
                    }
                };
                if (settings.fade_out) {
                    element.fadeOut('fast', function () {
                        deletion();
                    });
                } else {
                    deletion();
                }
            }

            return elements;
        }
function ( collection , settings , elements , element , index ) { if ( elements . length > settings . min && trueOrUndefined ( settings . before_remove ( collection , element ) ) ) { var deletion = function ( ) { var toDelete = element ; if ( ! settings . preserve_names ) { elements = shiftElementsUp ( collection , elements , settings , index ) ; toDelete = elements . last ( ) ; } var backup = toDelete . clone ( { withDataAndEvents : true } ) . show ( ) ; toDelete . remove ( ) ; if ( ! trueOrUndefined ( settings . after_remove ( collection , backup ) ) ) { var elementsParent = $ ( settings . elements_parent_selector ) ; elementsParent . find ( '> .' + settings . prefix + '-tmp' ) . before ( backup ) ; elements = collection . find ( settings . elements_selector ) ; elements = shiftElementsDown ( collection , elements , settings , index - 1 ) ; } if ( settings . position_field_selector ) { doRewritePositions ( settings , elements ) ; } } ; if ( settings . fade_out ) { element . fadeOut ( 'fast' , function ( ) { deletion ( ) ; } ) ; } else { deletion ( ) ; } } return elements ; }
removes the current element when clicking on a "delete" button and decrease all following indexes from 1 position.
removes the current element when clicking on a delete button and decrease all following indexes from 1 position .