【问题标题】:Accessing dropped item with jQuery/Ember framework使用 jQuery/Ember 框架访问丢弃的项目
【发布时间】:2012-05-09 13:32:37
【问题描述】:

我正在使用 ember.js 和 jQuery-ui 框架。目前,我能够让元素可拖动,并且可以在将项目放入特定 div 时触发事件。

但是,我无法获取拖放到 div 上的实际元素。传入的事件变量代表元素被拖放到的 div,'this' 代表一个 ember 对象。

我如何才能访问被丢弃的物品?

我正在使用的代码概览:

App.MyView = Em.View.extend({
    ...
    drag: function (event) {
        // This works correctly and the event here represents the actual element
        console.log("Dragging");
    },
    drop: function (event) {
        // This is where I am not able to access the dropped iem
        console.log("Dropped");
    },
    ...
});

谢谢

【问题讨论】:

    标签: javascript jquery-ui ember.js jquery-ui-droppable


    【解决方案1】:

    如果您使用 jQuery 可拖放/可拖放,ui.draggable 应该是您要查找的内容。

    http://jqueryui.com/demos/droppable/#event-drop

    drop: function(event, ui) { ... }

    在回调中,$(this) 表示可拖放的可拖放对象。 ui.draggable 代表可拖动对象。

    【讨论】:

      猜你喜欢
      • 2011-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多