jquery sortable 如何限制拖拽的个数

嫌疑人X 2015-05-09 11:37:53
$( ".target" ).sortable({
connectWith:".target",
placeholder: "item",
cursor: "move",
cursorAt: { left: 2, top : 2 },
revert: true,
}); 把class为item的div移动到class为target的div中,class 为target的div只允许有一个class为item的div,即是,如果一个div .target里面有了div .item再次拖动一个itemdiv进去时则拖不进去,
我修改的如下:
stop:function(e,ui) {
if($(e.toElement).attr("class") == "target") {
if ($(e.target).find(".item").length > 1) {
alert($(e.target).find(".item").length);
return false;
}
}
},在debug的模式下是可以很好的实现,但是非debug的模式下则实现不了,求解?
...全文
99 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

50,541

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧