同时需要可拖放ID的jqueryUI的ID [英] Need Id of BOTH draggable and droppable ID's jqueryUI

查看:89
本文介绍了同时需要可拖放ID的jqueryUI的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用下面的代码获取放置的物品的ID,但是如果我尝试更改警报以获取拖动物品的ID,则不会发生任何事情。例如alert(ui.draggable.attr(’id’));

I can get the id of the item I have dropped on with the below code, but if i try to change the alert to get the id of the dragged item, nothing happens. e.g. alert(ui.draggable.attr('id') );

 $(function() {
             function dropCallback(e) {
              alert("The firing droppable item was " + e.target.id );
                };


        $("#draggable").draggable({axis:"x"});
         var dropOpts = {
          accept:"#draggable",
          drop:dropCallback,
          greedy:true
        };


        $(".target").droppable(dropOpts);
    }); 


推荐答案

尝试使用...

drop:function(event,ui) {alert($(ui.draggable).attr("id"));}

这篇关于同时需要可拖放ID的jqueryUI的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆