2016-07-30 9 views
-2

uploadifiveの任意のメソッドをオーバーライドするコード例を教えてください。uploadifiveメソッドをオーバーライドする方法は?

ここで私は私のjsコードをputtedしてください、あなたの見てください。バックエンドから重複したファイルをチェックしたい私はすでにコントローラのメソッドを持っています。

私がどのようにメソッドをオーバーライドすることができるかのサンプルを与えるなら、私は先に試すことができます。

$('#file_upload').uploadifive({ 
    'auto'    : true, 
    'buttonText'   : 'Select File', 
    'checkScript'   : false, 
    'queueSizeLimit'  : 10, 
    'fileSizeLimit'  : 10737418240, 
    'dnd'     : false, 
    'multi'    : true, 
    'removeCompleted'  : true, 
    'queueID'    : 'queue', 
    'simUploadLimit'  : 30, 
    'uploadLimit'   : 30, 
    'overrideEvents'  : ['onProgress'], 
    'uploadScript'  : '/files/pending', 
    // Triggered for each file that is added to the queue 
    'onAddQueueItem' : function(file) { 
    console.log(file.name + "file that is added to the queue"); 
    var folder = files.currentItemData(); 
    this.data('uploadifive').settings.formData = { 
          'timestamp'      : current_date_time(), 
          'authenticity_token'   : token(), 
          'attachment[folder_id]'   : folder.id, 
          'attachment[context_code]'  : current_context_code(), 
          'attachment[language]'   : uploadifive_language_code(), 
          'success_action_status'   : "201", 
         //'attachment[duplicate_handling]': file.duplicate_handling, 
                }; 
    }, 
    // Triggered when a file is cancelled or removed from the queue 
    'onCancel'   : function() {}, 
    // Triggered when the server is checked for an existing file 
    'onCheck'   : function() {}, 
    // Triggered during the clearQueue function 
    'onClearQueue'  : function() {}, 
    // Triggered when files are dropped into the file queue 
    'onDrop'   : function() {}, 
    // Triggered when an error occurs 
    'onError'   : function(file, fileType, data) {}, 
    // Triggered if the HTML5 File API is not supported by the browser 
    'onFallback'  : function() {}, 
    // Triggered when UploadiFive if initialized 
    'onInit'   : function() {}, 
    // Triggered once when an upload queue is done 
    'onQueueComplete' : function(file, data) {}, 
    // Triggered during each progress update of an upload 
    'onProgress' : function(file, e) { 
    if (e.lengthComputable) { 
     var percent = Math.round((e.loaded/e.total) * 100); 
    } 
    $('.uploadifive-queue-item').find('.fileinfo').html(' - ' + percent + '%'); 
    $('.uploadifive-queue-item').find('.progress-bar').css('width', percent + '%'); 
    }, 
    // Triggered once when files are selected from a dialog box 
    'onSelect'   : function(file) { 
    console.log(file.queued + ' files were added to the queue.'); 
    return; 
    }, 
    // Triggered when an upload queue is started 
    'onUpload'   : function(file) { 
    console.log(file + ' files will be uploaded.'); 
    file_select_done(); 
    }, 
    // Triggered when a file is successfully uploaded 
    'onUploadComplete' : function(file, data) { 
    res_data = JSON.parse(data); 
    $.ajaxJSON(res_data.success_url,'GET',{"authenticity_token" : authenticity_token},function(data) { 
     if (data && data["attachment"]){ 
     var file_id = data["attachment"]["id"]; 
     var file_name = data["attachment"]["display_name"]; 
     generate_li(file_name, file_id); 
     qutaUpdate(); 
     } 
    }); 
    console.log('The file ' + file.name + ' uploaded successfully.'); 
    }, 
    // Triggered for each file being uploaded 
    'onUploadFile'  : function(file) { 
    console.log('The file ' + file.name + ' is being uploaded.'); 
    } 
});}); 
+0

あなたがまだ試したこと、失敗したことのコード例を教えてください。 – Thomas

+0

>>今見て、私は私のjsコードをputtedしてください、あなたの見てください。バックエンドから重複したファイルをチェックしたい私はすでにコントローラのメソッドを持っています。 >>メソッドをオーバーライドする方法についてサンプルを提供すれば、私は先に試すことができます。 – umishra

答えて

0

私は上記の質問の答えが見つかりました:私は、アレイ内のuploadifive方法をパット、今、すべての私のコードはここにいないの呼び出し:)

$('#file_upload').uploadifive({ 
    'overrideEvents'  : ['onProgress','onCheck'], 
}); 

をuploadifiveのコード。

ありがとうございます!

関連する問題