您如何获得已被拖放到可拖放目标上的 jQuery 小部件的上下文?
例如,这是使用此代码可拖动的小部件:
In the code that makes the images be draggable
ContentImageHolder.prototype = {
options: {
contentInfo: null,
},
getContentInfo: function(){
return this.options.contentInfo;
},
makeContentDraggable: function(){
$(this.element).draggable({
revert: true,
scroll: false,
start: $.proxy(this, 'dragStart'),
stop: $.proxy(this, 'dragStop'),
});
},
_init: function() {
this.makeContentDraggable();
}
$.widget("basereality.contentImageHolder", ContentImageHolder);
然后这是我的代码,使垃圾桶可以接受图像。
TrashCan.prototype = {
trashContent: function (event, ui){
//What do I do here to be able to access the functions of the dropped object
//droppedObject.getContentInfo();
},
_init: function() {
$(this.element).droppable({
drop: $.proxy(this, 'trashContent'),
});
},
}
$.widget.bridge('trashCan', TrashCan);
是否可以获取拖到可放置对象上的 ContentImageHolder 的上下文,以便我可以调用对象上的函数?
这里所有使用相似关键字的问题都说要使用ui.draggable
,但引用的是 DOM 对象,而不是 jQuery 小部件。那么是否有可能获得 jQuery 小部件?