我正在使用带有Carrierwave的jQuery-File-Upload进行多个文件上传。我正在上传多个文件,并希望在上传所有文件后重定向用户。这就是我现在这样做的方式:
jQuery ->
$('#new_update').fileupload
dataType: "script"
add: (e, data) ->
types = /(\.|\/)(gif|jpe?g|png)$/i
file = data.files[0]
if types.test(file.type) || types.test(file.name)
data.context = $(tmpl("template-upload", file))
$('#new_update').append(data.context)
else
alert("#{file.name} is not a gif, jpeg, or png image file")
$("#submit_button").on 'click', ->
data.submit()
progress: (e, data) ->
if data.context
progress = parseInt(data.loaded / data.total * 100, 10)
data.context.find('.bar').css('width', progress + '%')
目前我只是在同一页面上显示所有进度条,并且在上传所有文件后,我仍然在同一页面上。如何知道何时上传所有文件,以便将用户重定向到另一个页面?谢谢:))
答案 0 :(得分:1)
completed: function(e, data) {
//redirect in here
}