I make Jcrop inside .dialog() function. runs great, but i can’t pass my X and Y, etc. values!
function “updateCoords” works, but i cant passe it values throe Ajax! Fire Bug say that variables that I want to passe throe POST are not defined, but “HOW!” – i define variables in function updateCoords()! XD
function open_original(gallery_id, image_name){
$("#image_crop_canves").dialog({
modal:true,
width:634,
height:741,
buttons:{
"SAVE":function(){
$.ajax({
url: "send.php",
type: "POST",
data: "a=crop&x="+cx+"&y="+cy+"&w="+cw+"&h="+ch+"&gid="+gallery_id+"&id="+image_name,
success: function(){
$("#image_crop_canves").dialog('close');
window.location();
}
});
},
"CLOSE":function(){
$("#image_crop_canves").dialog('close');
}
}
});
$("#image_crop").html("<div id=\"image_holder_crop\"><img id=\"cropbox\" src=\"../../pics/gallery/" + gallery_id + "/original/" + image_name + "\" /></div>");
$("#image_crop_canves").dialog('open');
function updateCoords(c) {
var cx = c.x;
var cy = c.y;
var cx2 = c.x2;
var cy2 = c.y2;
var cw = c.w;
var ch = c.h;
}
$('#cropbox').Jcrop({
aspectRatio: 140/360,
onSelect: updateCoords,
setSelect: [0, 0, 140, 360],
minSize: [140, 360]
});
}
The problem is that you are declaring the variables in the
updateCoords(c)function, but are trying to access them outside of that function. This is not possible. What you can do is declare those variables in theopen_original(gallery_id, image_name)function ( before$("#image_crop_canves").dialog({ ... })) and then set their values from theupdateCoords(c)function, this way the variables will be accessible within the specified object.