joserinu
02-27-2012, 09:33 PM
I am trying to loop through each area and checking if they match the image class number then it should drop in correct place. You can see that i commented out the loop and if statement because it doesn't work. Can anyone shine light on this because i'm frustrated with this issue. :(
$(document).ready(function(){
var images = $('#clothes').find('img');
var drop = $('#dress').find('area');
for(var a=0; a < images.length; a++){
$( images[a] ).draggable( );
//alert($(images[i]).hasClass("20"));
if($(images[a]).hasClass("20")){
$( images[a] ).draggable({ revert: 'valid' });
//alert("WRONG");
}
else{
$( images[a] ).draggable({ revert: 'invalid' });
}
/*for(var b=0; b < drop.length; b++){
$( drop[k]).droppable({
activeClass: "ui-state-hover",
hoverClass: "ui-state-active",
drop: function( event, ui ) {
$( this ).addClass( "ui-state-highlight" )
/*if($(images[a]).attr('class').split(" ")[0] == $(drop[b]).attr('class')){
alert("RIGHT");
$(images[a]).draggable({ revert: 'invalid' });
}
else if($(images[a]).hasClass("20")){
$( images[a] ).draggable({ revert: 'valid' });
}
//alert("a = " + $(images[a]).attr('class').split(" ")[0] + " b = " + $(drop[b]).attr('class'));
}
});
}*/
}
});
$(document).ready(function(){
var images = $('#clothes').find('img');
var drop = $('#dress').find('area');
for(var a=0; a < images.length; a++){
$( images[a] ).draggable( );
//alert($(images[i]).hasClass("20"));
if($(images[a]).hasClass("20")){
$( images[a] ).draggable({ revert: 'valid' });
//alert("WRONG");
}
else{
$( images[a] ).draggable({ revert: 'invalid' });
}
/*for(var b=0; b < drop.length; b++){
$( drop[k]).droppable({
activeClass: "ui-state-hover",
hoverClass: "ui-state-active",
drop: function( event, ui ) {
$( this ).addClass( "ui-state-highlight" )
/*if($(images[a]).attr('class').split(" ")[0] == $(drop[b]).attr('class')){
alert("RIGHT");
$(images[a]).draggable({ revert: 'invalid' });
}
else if($(images[a]).hasClass("20")){
$( images[a] ).draggable({ revert: 'valid' });
}
//alert("a = " + $(images[a]).attr('class').split(" ")[0] + " b = " + $(drop[b]).attr('class'));
}
});
}*/
}
});