我有以下问题:
我正在为我的应用程序使用paper which introduced min-max heaps插件,但在克隆html并重新初始化插件时会有一些问题。
我正在销毁对象,以便在克隆新字段后使插件工作。问题是当我克隆时,选择的图像被删除了。有更好的方法吗?
HTML代码:
<div class="row">
<div class="col-md-5">
<div class="clone">
<div class="row fieldset-content">
<div class="col-md-12">
<br>
<div class="form-group">
<input class="slim" type="file" name="slim[]" />
</div>
</div>
</div>
<div class="clearfix"></div>
</div>
<button class="add_field_button btn btn-warning">+ Add more fields</button>
<button type="submit" class="btn btn-success" name="submit-normal">Save changes</button>
</div>
</div>
jquery代码:
<script>
$(document).ready(function() {
var options = {
ratio: '4:3',
label: 'Drop me here.',
instantEdit:true,
jpegCompression:true,
size:{
width: 640,
height: 480,
}
}
var cropper = $('.slim').slim(options);
$(document).on('click', '.add_field_button', function (e) {
e.preventDefault();
//destroy in order to get it working after clone
cropper.slim('destroy');
$('.fieldset-content').first().clone().appendTo('.clone');
$('.fieldset-content').first().find('.name').val('');
var rmvBtn = $('.fieldset-content').last().find('.remove-button');
//new instance
$('.slim').slim(options);
});
});
</script>