I have the following code, where there are 2 functions of draggable / droppable.
For each element that is placed well, I increase my variable by 1 to know that all the elements were placed well.
I did another function where I control that variable that I add, to say that if this variable is 2, I do something else ...
But this is not good for me (the IF of the 2nd script does not run), I need your help.
This script controls the placed elements and incremeta the 'totalShadows' var:
<script>
$(function () {
var totalSombras = 0;
$('#silueta1').droppable({
tolerance: 'fit',
hoverClass: 'active',
accept: "#objeto1",
drop: function(e, ui) {
$(this).html(ui.draggable.remove().html());
$(this).droppable('destroy');
$( this )
//.addClass( "ui-state-highlight" )
.attr("src", "images/jirafa.png");
var thissound = document.getElementById('colocarSilueta');
thissound.volume = 0.2;
thissound.play();
totalSombras = totalSombras + 1;
contar(totalSombras);
}
});
$('#silueta2').droppable({
tolerance: 'fit',
hoverClass: 'active',
accept: "#objeto2",
drop: function(e, ui) {
$(this).html(ui.draggable.remove().html());
$(this).droppable('destroy');
$( this )
.attr("src", "images/vaca.png");
var thissound = document.getElementById('colocarSilueta');
thissound.volume = 0.2;
thissound.play();
totalSombras = totalSombras + 1;
contar(totalSombras);
}
});
});
</script>
This script controls whether the 'totalShadows' var is worth 2:
<script>
jQuery(function contar(cont) {
if (cont == 2) {
alert("asd");
}
})
</script>