问题描述
我试图在我的隐藏模式事件块上的隐藏模式事件上销毁croppie实例,我的所有操作都运行良好,除了销毁croppie实例函数这里是我的代码:
function Updatetweetmedia(){
var id = document.getElementById('updatetwtID').value ;
$('.overlayUpdateTwtMeda').css({
'opacity':'1','visibility':'visible'
})
var el = document.getElementById('updtViewPort');
var resize = new croppie(el,{
viewport: {
width: 350,height: 350,type: 'square'
},boundary: {
width: '100%',height: 300
},showZoomer: true,enableOrientation: true
});
var reader = new FileReader();
reader.onload = function(e) {
resize.bind({
url: e.target.result,orientation: 1
});
}
reader.readAsDataURL(document.getElementById('updattwtmedia').files[0]);
document.getElementById('updatmediacropbtn').addEventListener('click',function(){
$('.overlayUpdateTwtMeda').css({
'opacity':'0','visibility:':'hidden'
})
$('.overlayUpdateTwtMeda222').css({
'opacity':'1','visibility':'visible'
})
resize.result({
type: 'canvas',size: {
width: '500',height: '350'
},quality: 1,format: 'jpeg'
}).then(function(img) {
var image = ' <img id="updateimgpreview" src="'+img+'" alt="" srcset="" width="500" height="350">';
$('.updtetwtpreview').append(image);
})
})
document.getElementById('UpdateTweetModal').addEventListener('hidden.bs.modal',function(){
// document.getElementById('updtViewPort').innerHTML = '';
// $('#updtViewPort').html('');
// $('#updattwtmedia').val('');
// $('.overlayUpdateTwtMeda').css({
// 'opacity':'0',// 'visibility':'hidden'
// })
// $('.overlayUpdateTwtMeda222').css({
// 'opacity':'0',// 'visibility':'hidden'
// })
$('#updtViewPort').croppie('destroy');
}) }//end of Updatetweetmedia function
我所有的叠加 div 和我的模态一样工作得很好,但是据我所知,当croppie 初始化时,它添加了croppie-container 类和一些子节点,我尝试删除这些节点并重置我的输入文件的值,但是在尝试重新初始化它时会抛出croppie.js:1543 未捕获错误:croppie:无法多次初始化croppie 我真的很感激这里的任何帮助,并提前致谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)