modalpopupextender 中 Jcrop(image).setOptions 的 jquery 委托事件
我有一个 modalpopupextender 控件,用于在将图像保存到文件系统之前上传和裁剪图像。
MPE 首先显示一个文件上传控件,当用户上传文件时,它会在其下方显示带有上传图像的裁剪部分。它第一次工作,它显示图像并使用 Jcrop javascript/jquery
文件,我可以裁剪框架并保存裁剪后的图像。
初始化 Jcrop 的代码位于下面的 jQuery(window).load 函数中。
$.Jcrop(image).setOptions({
onChange: update,
onSelect: update,
aspectRatio: myRatio,
bgColor: 'white',
bgOpacity: 0.5
});
但是,当用户尝试在不关闭弹出窗口的情况下再次上传另一个文件时,就会出现问题。它不运行 jcrop 的更新方法,我相信该方法仅在第一次加载弹出窗口时运行。我需要将诸如实时事件处理程序之类的东西附加到它,但我无法这样做。我尝试按如下方式附加绑定事件,但它不起作用。
$.Jcrop(image).bind('setOptions', { onChange: update,
onSelect: update,
aspectRatio: forcedRatio,
bgColor: 'black',
bgOpacity: 0.6
}, function () {
alert('test');
});
有没有人以前以类似的方式使用过 JCrop 或者有关于如何处理这个问题的想法?
I have a modalpopupextender
control that is used to upload and crop an image before saving it to the file system.
MPE shows a file upload control first, when the user uploads a file, it shows the cropping section beneath it with the uploaded image. It works the first time, it shows the image and using Jcrop javascript/jquery
file, I can crop the frame and save the cropped image.
The code that initializes Jcrop is below in the jQuery(window).load
function.
$.Jcrop(image).setOptions({
onChange: update,
onSelect: update,
aspectRatio: myRatio,
bgColor: 'white',
bgOpacity: 0.5
});
But the problem happens when the user tries to upload another file again without closing the popup. It does not run the update method for jcrop which I believe only runs on the first time the popup is loaded. I need to attach something like a live event handler to it but i'm unable to do so. I tried attaching a bind event as below but it does not work.
$.Jcrop(image).bind('setOptions', { onChange: update,
onSelect: update,
aspectRatio: forcedRatio,
bgColor: 'black',
bgOpacity: 0.6
}, function () {
alert('test');
});
Has anyone used JCrop in a similar fashion before or any ideas on how to handle this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于未来的访问者,我可以通过在
window.focus
而不是window.load
中使用 setOptions 事件来使其工作。For future visitors, I was able to make it work by having the setOptions event inside the
window.focus
instead ofwindow.load
.