From ba71aa16a3f82af1b1732b9d9b583de317d3027c Mon Sep 17 00:00:00 2001 From: Arian Date: Mon, 6 Jun 2011 17:19:34 +0200 Subject: [PATCH] Fixes #1 - IE7 crashed when cloning an element multiple times. Also fix the label for and input id attributes in the legacy uploader More info about that crash in IE7: https://mootools.lighthouseapp.com/projects/2706/tickets/1196-cloning-element-twice-crashes-ie7#ticket-1196-6 --- Source/Form.Upload.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Source/Form.Upload.js b/Source/Form.Upload.js index 4821c35..d6fff2f 100644 --- a/Source/Form.Upload.js +++ b/Source/Form.Upload.js @@ -87,12 +87,15 @@ Form.Upload = new Class({ legacyUpload: function(input){ var row = input.getParent('.formRow'); - rowClone = row.clone(), + rowClone = row.clone(true, true), add = function(event){ event.preventDefault(); - var newRow = rowClone.clone(); - newRow.getElement('input').grab(new Element('a.delInputRow', { + var newRow = rowClone.clone(true, true), + inputID = String.uniqueID(), + label = newRow.getElement('label'); + + newRow.getElement('input').set('id', inputID).grab(new Element('a.delInputRow', { text: 'x', events: {click: function(event){ event.preventDefault(); @@ -100,6 +103,7 @@ Form.Upload = new Class({ }} }), 'after'); + if (label) label.set('for', inputID); newRow.inject(row, 'after'); };