2012-01-11 2 views
1

좋아요. 업로드 대기열을 지우고 테스트 할 수있는 몇 가지 테스트 코드를 작성했지만 현재 위치에서 refresh() 함수에 액세스하는 방법을 모르겠습니다. jQuery UI 위젯을 기본으로 사용하고 있습니다. INIT를 사용하는 부분이 나에게 지옥을주고 있는데, 내 json 호출에서 refresh()하는 방법을 알아낼 수 없습니다. 분명히 jQuery를 빨아 들인 것처럼 나를 계몽 할 수 있기를 바랍니다.jQuery UI 위젯을 Plupload하고 대기열을 새로 고침

var do_continue = false; 

    $("#uploader").plupload({ 
    // General settings 
    runtimes : 'html5,browserplus,silverlight,gears,html4', 
    url : CI.base_url + 'private/ad/upload_ad_images', 
    max_file_size : '2mb', 
    max_file_count: 5, // user can add no more then 20 files at a time 
    //chunk_size : '1mb', 
    unique_names : true, 
    multiple_queues : true, 

    // Resize images on clientside if we can 
    //resize : {width : 800, height : 600, quality : 90}, 

    // Rename files by clicking on their titles 
    rename: true, 

    // Sort files 
    sortable: true, 

    // Specify what files to browse for 
    filters : [ 
     {title : "Image files", extensions : "jpg,gif,png"} 
    ], 

    // Flash settings 
    flash_swf_url : CI.base_url + 'scripts/plupload/js/plupload.flash.swf', 

    // Silverlight settings 
    silverlight_xap_url : CI.base_url + 'scripts/plupload/js/plupload.silverlight.xap', 
    // Post init events, bound after the internal events 
    init : { 
     QueueChanged: function(up) { 
      // check for max photos here 
      $.getJSON(CI.base_url + 'private/ad_ajax/count_uploaded_images/', function(data) { 
      if (!data.message) { 
       alert("no data found? - please contact us with this message."); 
       do_continue = false; 
      }else if(data.message != "go") { 
       alert("Maximum photo uploads reached."); 
       do_continue = false; 
      } 
      if (!do_continue) { 
       $(this).refresh(); // -->> need something that works here 
      } 
      }); 
     } 
    } 
}); 

답변

1
$.getJSON(CI.base_url + 'private/ad_ajax/count_uploaded_images/', function(data) { 
if(data.message != "go") { 
    alert("Maximum photo uploads reached."); 
    do_continue = false; 
    plupload.each(files, function(file) { 
     up.removeFile(file); 
    }); 
} 
}); 

답변 - up.refresh() 등은 어떤 이유로 작동하지 않았습니다.

+0

'uploader.splice();'는 대기열을 지우기에 충분합니다 .. 어쩌면 jquery.ui 또는 플래시 플러그인을 사용하여 나중에 새로 고침해야합니다. – ppumkin

3

정확히 UI에서 새로 고치려고하십니까? 지금까지 내가 아는 한 refresh()는 올바른 위치의 런타임에 대해 plupload 투명 심을 다시 그립니다. 전체 UI를 다시로드하거나 업로드 대기열을 새로 고치거나 지우지 않습니다.

새로 고침을 시도하는 이유와 이유에 대해 좀 더 자세히 설명해 주시면 추가로 도움을 드릴 수 있습니다.

up.refresh(); 

당신은 완전히 그대로 이루어집니다 업로드 대기열을 비우려고 노력하는 경우는 다음과 같습니다 :

up.splice(); 

또는 다른 곳에서 코드 내에서 다음과 같이 어느 쪽이든은,라고 당신의 코드를 기반으로 리프레시 사용 :

var uploader = $('#uploader').plupload('getUploader'); 
uploader.splice(); 

것은 또한 당신이 오히려 QueueChanged 만에 의존적보다는 FilesAdded에 수표를 일을해야 의심으로 사용 가능한 다른 events으로 확인 할 수 있습니다 당신이 성취하려고 노력하고있는 것.

+0

$ (this) .refresh()는 QueueChanged : function (up) {$ (this) .refresh()}에 직접 넣을 때 업로드 대기열을 새로 고치는 것처럼 보입니다. $ .getJSON을 통해 가져 오는 최대량의 사진에 도달 할 때만 새로 고침하고 싶습니다. 그러나 (this) getJSON 함수 내에서 액세스 할 수 없습니다. 난 그냥 getJSON 함수 내에서 새로 고침/splice에 액세스하는 방법을 알아야합니다. – qwertzman

관련 문제