2011-01-18 32 views
6

到目前为止,我的uploadify实现运行相对平稳,除了一个唠叨的问题。Uploadify + jQuery UI

我有我的uploadify浏览提示在jquery-ui对话框模式窗口中。 文件上传正常,但对于每个选定的文件项目,会出现两个相同的队列项目(相同的ID)。

只有其中一个队列项实际上使用进度条更新,尽管两者似乎都获得了更新百分比。

文件上传完成后,只有其中一个队列项目(与进度栏一起更新的队列项目)被删除。

alt text

我测试了jQuery UI的对话模式窗口和双队列项行为消失之外。

我很想保持uploadify提示,如果可能的话,在模态对话窗口中排队。

任何线索为什么在jquery-ui模式窗口中使用uploadify导致这种双重队列项目行为?

UPDATE:

$("#Filedata").uploadify({ 
'scriptAccess': 'allways', 
'uploader'  :'<?php echo base_url();?>js/jquery.uploadify-v2.1.4/uploadify.allglyphs.swf', 
'script': '<?php echo site_url();?>/upload/process_upload', 
'cancelImg': '<?php echo base_url();?>js/jquery.uploadify-v2.1.4/cancel.png', 
'folder'   : '/', 
'fileDataName'  :'Filedata', 
'buttonText' : 'Document...', 
'width': '273', 
'height': '51', 
'wmode': 'transparent', 
'auto'   : true, 
'multi'   : false, 
'fileExt' : '*.pdf;', 'fileDesc' :'Document', 
'sizeLimit' : 10485760, 
'simUploadLimit' : 1, 
'queueSizeLimit' :'1', 
'uploaderType' : 'flash', 
'scriptData' : {'userdata':'<?php echo $userdata;?>','upload_token':'<?php echo $token['value'];?>'}, 
    onProgress: function() { 
    //hide upload button 
    $("object#FiledataUploader").height(0); 
    }, 

//workaround for bug in jQuery UI dialog/upoadify (double progress bars) 
onOpen  : function(event,ID,fileObj) { 
    $('#FiledataQueue div.uploadifyQueueItem:first-child').hide(); 
    }, 

onError: function(a, b, c, d) { 
if (d.status == 404) 
alert('Could not find upload script. Use a path relative to: ' + '<?= getcwd() ?>'); 
else if (d.type === "HTTP") 
alert('error ' + d.type + ": " + d.info); 
else if (d.type === "File Size") 
alert(c.name + ' ' + d.type + ' Limit: ' + Math.round(d.sizeLimit/1024) + 'KB'); 
else 
alert('error ' + d.type + ": " + d.info); 
}, 
onComplete : function (event, queueID, fileObj, response, data) { 
    var r = JSON.parse(response); 
    $('#token').val(r['token']);          
    $('#uploaded_filename').val(r['uploaded_filename']); 
    $('#filename_encryption').val(r['encryption']); 
    $('#FiledataQueue').html('Document <span class="bold" style="font-weight:bold;">'+ r['filename'] + '</span>'); 
}, 

onQueueFull: function(event, queueSizeLimit) { 
// supress dialog that mentions the queue is full 
return false; 
} 
}); 

HTML:

<form id="form-document" method="" action=""> 
    <input type="file" name="Filedata" id="Filedata" size="20" /> 
    <input type="hidden" name="response" id="response" value=""/> 
    <input type="hidden" name="upload_token" id="upload_token" value=""/> 
    <input type="hidden" name="uploaded_filename" id="uploaded_filename" value=""/> 
    <input type="hidden" name="filename_encryption" id="filename_encription" value=""/> 
    <input type="hidden" name="uploaded_extension" id="uploaded_extension" value=""/> 
    <input type="hidden" name="token" id="token" value="<?php echo $token['value'];?>"/> 
    </form> 

更新2:

jQuery用户界面对话框:

dialog_data.dialog({ 
    autoOpen: false, 
    height: 700, 
    width: 800, 
    modal: true, 
    bigframe: true, 
    buttons: { 
    'Save': function() { 
    $.ajax({ 
    type: "GET", 
    url: "<?php echo site_url();?>/upload/finish", 
    dataType: 'html', 
    data: $('#form-document').serialize(), 
    success: function(){ 
     oCache.iCacheLower = -1; 
     oTable.fnDraw(); 
     dialog_data.dialog('close'); 
    } 
    }); 
    }, 
    'Close': function() { 
    $(this).dialog('close'); 
    $('.loading').hide(); 
    } 
    }, 
    open: function(){ 
    $('.loading').hide(); 
    $("object#FiledataUploader").height(30); 
    }, 
    close: function() { 
    $('#uploaded_filename').val(''); 
    $('#filename_encription').val(''); 
    $('#FiledataQueue').html(''); 
    } 
}); 
+0

我解决了它解决方案的解决方案,但我不满意解决方法。我想知道更多关于这个(可能)错误的信息。 – mojeime 2011-01-18 23:13:47

+0

你的代码好吗? – ifaour 2011-01-19 00:23:43

回答

1

如果您将另一个ID和名称提供给您的文件字段,您可以尝试检查会发生什么情况。 Filedata是上传脚本中使用的变量,无论您向字段提供的ID /名称如何,我都会问是否可能没有冲突。

所以我会说尝试更改ID,并将ID参数添加到您的uploadify设置(以新ID作为值),并让我们知道是否可以解决问题。

0

这是错误的解决方案吗?

//workaround for bug in jQuery UI dialog/upoadify (double progress bars) 
onOpen  : function(event,ID,fileObj) { 
    $('#FiledataQueue div.uploadifyQueueItem:first-child').hide(); 
    }, 
0

此错误在没有功能getAttributeNode并在Flash元件getAttribute

变化 “jQuery的min.js”

elem.getAttributeNode(name) // OR a.getAttributeNode(b) 

(elem.getAttributeNode?elem.getAttributeNode(name):null) // OR (a.getAttributeNode?a.getAttributeNode(b):null) 

elem.getAttribute(name) // OR a.getAttribute(b) 

(elem.getAttribute?elem.getAttribute(name):null) // OR (a.getAttribute?a.getAttribute(b):null)