【发布时间】:2012-09-07 19:45:17
【问题描述】:
大家早上好,
我与这个问题斗争了 3 个小时,但我找不到获胜的方法 XD 我有一个 ajax 上传,成功后将打开一个 twitter 引导模式窗口,该窗口将加载图像,初始化 jcrop,然后在关闭时根据选择生成拇指。
这很好用...真正的麻烦是我需要在模态中释放选择,这是我按照 jcrop 网站上的说明进行操作但我无法退出的问题。
现在我已经解释了问题,是时候编写一些代码了:D
var FileUploader_img_frontale = new qq.FileUploader({
'element':document.getElementById("img_frontale"),
'debug':false,
'multiple':false,
'action':'http://url.com/upload',
'allowedExtensions':['jpg','png','jpeg','gif'],'sizeLimit':10485760,
'onComplete':function(id, fileName, responseJSON){
$('#pbar_img_frontale').css('display','none');
$('#img-front-body').html('<img id="cropbox1" src="url.com/images/tmp/b444ac06613fc8d63795be9ad0beaf55011936ac/'+responseJSON.filename+'" style="max-width:400px;max-height:400px;"/>');
function showCoordsFront(c){ $('#_opera_img_frontale').val(responseJSON.filename+'|'+c.x+'|'+c.y+'|'+c.x2+'|'+c.y2+'|0'); }
$('#cropbox1').Jcrop({
boxHeight: 400,
boxWidth:400,
trueSize: [responseJSON.width,responseJSON.height],
allowResize: true,
aspectRatio: 4/3,
onChange: showCoordsFront,
onSelect: showCoordsFront,
},function(){ jcrop1 = this; });
$('#_opera_img_frontale').val(responseJSON.filename);
front_uploaded=1;
$('#modal_img_front').modal('toggle');
},'onProgress':function(id, fileName, loaded, total){ $('#pbar_img_frontale').css('display','block'); $('#bar_img_frontale').css('width',((loaded*100)/total)+'%'); },'params':{'PHPSESSID':'400659255ef857e043b5ab1651406f50','YII_CSRF_TOKEN':'c8248bc34b5371edf162292691dbcf23dc1e697a'}});
这是上传文件的 jquery ajax,你可以看到我已经放了
function(){ jcrop1 = this; }
需要抓取 obj,但是当我不通过 ajax 上传图像时它可以工作,但我不明白如何处理它导致释放按钮在 jquery 就绪时将 jcrop1 设置为未定义
var jcrop1;
$("#jcrop1-release").click(function(){
jcrop1.setSelect([0,0,0,0]);
jcrop1.release();
});
谁能帮帮我?
提前致谢
法比奥
【问题讨论】:
-
复杂吧?我无法摆脱它,这让我发疯......如果我在 jcrop1=this 显然返回对象之后发出警报,但在那之后似乎 jcrop1 消失在空气中T_T