学习YUI.Ext第五日--做拖放Darg&Drop

2019-06-03 01:56:00王旭

        for (key in answer) { 
            if (answer[key] == dropzone.id) { 
                return false;      
            } 
        } 
        return true; 
    } 

    Draggable.prototype.startDrag = function(x, y) { 
        YAHOO.util.Dom.setStyle(this.getEl(), "opacity", 0.5); 
    } 

    Draggable.prototype.onDragEnter = function(e, id) { 
        var dropzone = YAHOO.util.DDM.getElement(id); 
        var draggable = this.getEl(); 
        if (this.canAccept(draggable, dropzone)) { 
            dropzone.style.backgroundColor = "orange"; 
        } 
    } 

    Draggable.prototype.onDragOut = function(e, id) { 
        var dropzone = YAHOO.util.DDM.getElement(id); 
        dropzone.style.backgroundColor = "white"; 
    } 

    Draggable.prototype.onDragDrop = function(e, id) { 
        var dropzone = YAHOO.util.DDM.getElement(id); 
        var draggable = this.getEl(); 
        if (this.canAccept(draggable, dropzone)) { 
            dropzone.style.backgroundColor = "white"; 
            dropzone.appendChild(draggable); 
            answer[draggable.id] = dropzone.id;         // 解答更新 
        } 
    } 

    Draggable.prototype.endDrag = function(e) { 
        var draggable = this.getEl();