이미지를 업로드하기 위해 dropzonejs 플러그인이있는 Rails 애플리케이션이 있습니다. Album
이미지가 업로드되기 직전에 만들고 있습니다. 그런 다음 새 앨범에 사진을 업로드하고 싶습니다.
Dropzone.options.myDropzone = {
init: function() {
this.on("processing", function(file) {
# Performing album creation via $.ajax
# $.ajax return ID of an album, but JS already skipped before I set new URL
});
}
};
요청이 완료 될 때까지 기다렸다가 반환 된 ID를 url 옵션으로 올바르게 설정하려면 어떻게해야합니까?
이 경우 accept를 사용할 수 있습니다.
Dropzone.options.myDropzone = {
accept: function(file, done)
{
file.postData = {};
$.ajax({
url: '/album',
data: {name: file.name, type: file.type},
type: 'POST',
success: function(response)
{
file.album_id = response.album_id;
done();
},
error: function(response)
{
done('error preparing the file');
}
});
},
init: function() {
this.on("processing", function(file) {
# Do other stuffs if needed
});
}
};
이제 dropbox는 drop ()이 호출 될 때까지 기다립니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다