jqueryui在某些元素上禁用Drop
我有一个jQueryUI可拖动代码,我用JSLUB编写 问题是用户可以将圆放在另一个圆上,我不允许这样做, 如果用户将圆圈拖放到另一个圆圈上,我只需还原即可。 我为此写了一些代码。但这对我不起作用,它总是恢复下降的圆圈。 下面是我的示例url 这是我在FireBug上运行的js代码jqueryui在某些元素上禁用Drop,jquery,jquery-ui,drag-and-drop,jsplumb,Jquery,Jquery Ui,Drag And Drop,Jsplumb,我有一个jQueryUI可拖动代码,我用JSLUB编写 问题是用户可以将圆放在另一个圆上,我不允许这样做, 如果用户将圆圈拖放到另一个圆圈上,我只需还原即可。 我为此写了一些代码。但这对我不起作用,它总是恢复下降的圆圈。 下面是我的示例url 这是我在FireBug上运行的js代码 $(".circle").draggable({ revert: 'invalid' }); $(".circle").droppable({ accept: function(el) {
$(".circle").draggable({
revert: 'invalid'
});
$(".circle").droppable({
accept: function(el) {
return el.hasClass('.circle');
}
});
请帮我做那件事
还有一个小问题-我们可以跟踪此恢复事件吗,我需要在恢复圆时重新绘制线条:)这里正在工作
首先设置可拖动事件的选项:
var revTest=false;
var options = {
revert: function(socketObj){
if(socketObj === false){ //when circle is not over circle
revTest = false; //we don't want to revert
return false;
}else{ //when circle is over circle
revTest = true; //revert the action
return true;
}
},
scope:"Circle",
stop: function(e , ui){
if(revTest === true){
alert("Circle cannot overlay Circle");
jsPlumb.repaint(this.id); // needed if the element is associated with jsPlumb endpoints or connections
}
}
};
$("#Circle1").droppable({scope:"Circle"});
现在包括可拖动元素的选项:
jsPlumb.draggable($("#Circle2"),options);
对于可拖放事件:
var revTest=false;
var options = {
revert: function(socketObj){
if(socketObj === false){ //when circle is not over circle
revTest = false; //we don't want to revert
return false;
}else{ //when circle is over circle
revTest = true; //revert the action
return true;
}
},
scope:"Circle",
stop: function(e , ui){
if(revTest === true){
alert("Circle cannot overlay Circle");
jsPlumb.repaint(this.id); // needed if the element is associated with jsPlumb endpoints or connections
}
}
};
$("#Circle1").droppable({scope:"Circle"});
这里正在工作
首先设置可拖动事件的选项:
var revTest=false;
var options = {
revert: function(socketObj){
if(socketObj === false){ //when circle is not over circle
revTest = false; //we don't want to revert
return false;
}else{ //when circle is over circle
revTest = true; //revert the action
return true;
}
},
scope:"Circle",
stop: function(e , ui){
if(revTest === true){
alert("Circle cannot overlay Circle");
jsPlumb.repaint(this.id); // needed if the element is associated with jsPlumb endpoints or connections
}
}
};
$("#Circle1").droppable({scope:"Circle"});
现在包括可拖动元素的选项:
jsPlumb.draggable($("#Circle2"),options);
对于可拖放事件:
var revTest=false;
var options = {
revert: function(socketObj){
if(socketObj === false){ //when circle is not over circle
revTest = false; //we don't want to revert
return false;
}else{ //when circle is over circle
revTest = true; //revert the action
return true;
}
},
scope:"Circle",
stop: function(e , ui){
if(revTest === true){
alert("Circle cannot overlay Circle");
jsPlumb.repaint(this.id); // needed if the element is associated with jsPlumb endpoints or connections
}
}
};
$("#Circle1").droppable({scope:"Circle"});