0

一連の画像を含むデータビューがある場所にドラッグ アンド ドロップを作成しています。次に、ユーザーがデータビューから画像をドロップできるようにするパネルがあります。sencha examples の例を使用して、このようなものを得ることができました。しかし、私はエラーが発生しています

Uncaught TypeError: Cannot set property 'afterValidDrop' of undefined 

これは私のパネルにあるものです。

Ext.define('Memegen.view.MemeBuildArea',{
    extend: 'Ext.panel.Panel',
    alias: 'widget.memebuildarea',
    listeners: {
        render: initializeMemeDropZone
    },
    cls: 'meme-target',
});

function initializeMemeDropZone(targetPanel) {  
    targetPanel.dropTarget = Ext.create('Ext.dd.DropTarget', targetPanel.el);
    targetPanel.dropTarget.notifyDrop = function(source, evt, data) {
    if(typeof console != "undefined")
      console.log("notifyDrop:" + source.id);
    var droppedPanel = Ext.getCmp(source.id);

    droppedPanel.dd.afterValidDrop = function() {
      targetPanel.add(droppedPanel.cloneConfig({
        draggable: false,
        title: "Can't Drag This Panel."
      }));
      droppedPanel.destroy();
    };
    return true;
}

  targetPanel.dropTarget.notifyEnter = function(source, evt, data) {
    if(typeof console != "undefined")
      console.log("notifyEnter:" + source.id);
    return this.callParent(Array.prototype.slice.call(arguments));
  };

  targetPanel.dropTarget.notifyOut = function(source, evt, data) {
    if(typeof console != "undefined")
      console.log("notifyOut:" + source.id);
    return this.callParent(Array.prototype.slice.call(arguments));
  };

  targetPanel.dropTarget.notifyOver = function(source, evt, data) {
    if(typeof console != "undefined")
      console.log("notifyOver:" + source.id);
    return this.callParent(Array.prototype.slice.call(arguments));
  };

}

ここで何がうまくいかないのかについてのアイデアはありますか?

4

1 に答える 1

0

dd プロパティを定義するには、パネルがドラッグ可能である必要があります (Ext.panel.Panel の API ドキュメント、ドラッグ可能な構成を参照してください)。

于 2013-01-15T20:47:02.673 に答える