2013-12-17 131 views
1

我有一個簡單的jquery進度條來表示文件上傳,我希望在每次上傳後重置它。restating jquery進度條

我已經試過這在我的腦海裏應該工作...但沒有下文,

$('#fileupload').fileupload({ 
    dataType: 'json', 
    url: 'Home/UploadFiles', 
    autoUpload: true, 
    done: function (e, data) { 
     $('.file_name').html(data.result.name); 
     $('.file_type').html(data.result.type); 
     $('.file_size').html(data.result.size); 
     alert("File was uploaded"); 
     $('.file_name').html(""); 
     $('.file_type').html(""); 
     $('.file_size').html(""); 
     //this is where I am attempting to reset the bar after 1.5 secs 
     setTimeout(function() { 
      $('#progress .progress-bar').css('width', 0); 
     }, 1500); 

    } 
}).on('fileuploadprogressall', function (e, data) { 
    var progress = parseInt(data.loaded/data.total * 100, 10); 
    $('.progress .progress-bar').css('width', progress + '%'); 
}); 

回答

2

你做錯了改變進度條的,你需要改變valueposition

$(".progress").progressbar({ value: 25 }); 

請參閱:http://api.jqueryui.com/progressbar/#option-value

+0

謝謝。我也注意到一個語法錯誤,我糾正了,現在看起來很好。 $('。progress .progress-bar')。css('width',0); – Arianule