正确的,
我在这里有这段代码:
var dfd1 = $.Deferred();
var dfd2 = $.Deferred();
$( "#draggable" ).draggable({
revert: "invalid",
snap: "#droppable",
});
$( "#droppable" ).droppable({
accept: "#draggable",
drop: function() {
$("#whistle").get(0).play();
dfd1.resolve();
}
});
$( "#draggable2" ).draggable({
revert: "invalid",
snap: "#droppable",
});
$( "#droppable2" ).droppable({
accept: "#draggable2",
drop: function() {
$("#whistle").get(0).play();
dfd2.resolve();
}
});
var done = $.when(dfd1.promise(), dfd2.promise())
done.then(function(){
$("#whistle2").get(0).play();
alert ("done!")
});
我一直在尝试添加这样的东西:
if(done.state("#sec_a_div") == "resolved"){
$("#sec_a_th").css("background-color"="green")
}
else {
$("#sec_a_th").css("background-color"="yellow")
}
问题是,有几个 sec id'd div。我想知道,也许有人可以向我解释,如何使这些 dfd 对这个 div 是唯一的,也许然后如何根据状态改变缩略图的颜色。我希望我尽可能清楚。