当我尝试通过单击按钮 IE8 将元素添加到 div 时,不要添加它,直到我第二次按下它。然后它添加了两个新元素。这是代码:
$(options.addButton).click(function(event) {
var prototype = $(options.prototypeContainer).attr('data-prototype');
event.preventDefault();
var fileField = $(prototype.replace(/__name__/g, fieldCount));
fieldCount++;
$(options.uploadingImagesWrapper).append(fileField);
//fileField.slideDown();
return false;
});
容器的标记如下所示:
<div id="uploading-component-images">
<!-- here I inserts new elements -->
</div>
<!-- the button the triggers insertion function -->
<a class="btn" href="#" id="add-another-image">{{'label.component.add_image_field'|trans }}</a>
单个元素标记如下所示:
<div class="image-file-field">
<input type="file" name="{{ full_name }}[file]" id="{{ id }}" />
<button type="button" class="offset0_5 remove-image btn btn-mini">
<span class="icon-remove"></span>
</button>
</div>
这是一个屏幕截图-也许有了它会更容易理解。http://joxi.ru/RFBeUtg5CbBaNyCgm14 jquery的版本是1.9.1