2014-06-19 3 views
-2

이 드래그 앤 드롭을 구현했습니다 : http://hayageek.com/drag-and-drop-file-upload-jquery/.끌어서 놓기 jquery 제거 문제

내가 파일을 추가

, 다음 내가 그것을 제거 :

그것은 내 문제는 다음입니다, 잘 작동하지만. 다른 파일을 추가 할 때 "제거 된"파일은 다시 나타나지만 버튼을 제거하지 않고 나타납니다 ...

나는 이것을 해결하기가 절실합니다.

문제는 처리기 또는 삭제 기능에 있다고 생각합니다. 그러나 나는 그것을 발견 할 수 없다. 어쩌면 나는 휴식이 필요하다. ...

$(document).ready(function() { 

$("#errorMessages").hide(); 
// Handle drag and drop events with jQuery 
var obj = $("#dragandrophandler"); 
obj.on('dragenter', function (e) { 
    e.stopPropagation(); 
    e.preventDefault(); 
    $(this).css('border', '2px solid #0B85A1'); 
}); 
obj.on('dragover', function (e) { 
    e.stopPropagation(); 
    e.preventDefault(); 
}); 
obj.on('drop', function (e) { 
    $(this).css('border', '2px dotted #0B85A1'); 
    e.preventDefault(); 
    var files = e.originalEvent.dataTransfer.files; 
    cleanErrorMessages(); 
    //We need to send dropped files to Server 
    handleFileUpload(files, obj, uploadURL); 
}); 

// If the files are dropped outside the div, file is opened in the browser window. To avoid that we can prevent ‘drop’ event on document. 
$(document).on('dragenter', function (e) { 
    e.stopPropagation(); 
    e.preventDefault(); 
}); 
$(document).on('dragover', function (e) { 
    e.stopPropagation(); 
    e.preventDefault(); 
    obj.css('border', '2px dotted #0B85A1'); 
}); 
$(document).on('drop', function (e) { 
    e.stopPropagation(); 
    e.preventDefault(); 
}); 

$("#file").change(function() { 
    cleanErrorMessages(); 
}); 

// add file to the list using the input 
$("#addFile").click(function (evt) { 
    evt.preventDefault(); 
    var files = $("#file")[0].files; 
    handleFileUpload(files, obj); 
    $("#file").val(""); 
    return false; 
}); 

}});

더 많은 코드가 있지만이 부분에 문제가 있어야한다고 생각합니다. 내가 해결책을 찾으면 나는 그것을 게시 할 것이다.

제거 기능 :

this.remove.click(function (evt) { 
    // TO DO: call to the WS to remove from the server 
    var numrow = evt.currentTarget.parentElement.attributes[1].value; 
     evt.currentTarget.parentElement.removeChild(evt.currentTarget); 
    $(".statusbar[numrow='" + numrow + "']").fadeOut(1000, "easeInOutCubic", function (evt) { 
    }); 
}); 
+1

코드를 공유하십시오 – martynas

+0

그래, 죄송합니다. 게시물을 편집합니다 – SrAxi

+0

제거 기능을 추가했습니다. 아마도 문제가되고 있습니다. – SrAxi

답변

0

는 제거 기능을 변경 :

this.remove.click(function (evt) { 
    // TO DO: call to the WS to remove from the server 
    var numrow = evt.currentTarget.parentElement.attributes[1].value; 
     evt.currentTarget.parentElement.remove(evt.currentTarget); 
    $(".statusbar[numrow='" + numrow + "']").fadeOut(1000, "easeInOutCubic", function (evt) { 
    }); 
}); 

그냥 변경했다 : evt.currentTarget.parentElement.removeChild(evt.currentTarget);이를 위해 : evt.currentTarget.parentElement.remove(evt.currentTarget);.