2011-08-09 129 views
3

里面我有一个jQuery UI的对话框中,该包含<form>含有<input type=file>文件对话框不会出现一个jQuery-UI-对话框

对于我的一些用户,当他们点击按钮打开文件对话框:它没有出现。

,因为有这个问题将能够使用他们所有已安装的浏览器来重现电脑问题的基础不是浏览器:

  • 火狐
  • 的Internet Explorer

的问题不是基于操作系统,因为我已经看到问题的发生:

  • 视窗XP
  • Windows 7的
  • 的Kubuntu 11.04

我已经与操作系统安装虚拟机和文件对话框将可以正常使用。

所以我的问题是:任何人有任何想法是怎么回事?

这里的 “代码”:

<meta charset="utf-8"> 

    <link rel="stylesheet" href="http://matchfwd-statics.s3-website-us-east-1.amazonaws.com/asset_cache/css/e1b34bd841d9.css" type="text/css" media="all"> 
    <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'> 

<script> 

     $(function() { 
     $("#dialog-form").dialog({ 
      autoOpen: false, 
      height: 500, 
      width: 550, 
      modal: true, 
      buttons: { 
      "Send": function() { 
       $(this).dialog("close"); 
      }, 
      Cancel: function() { 
      $(this).dialog("close"); 
      } 
      }, 
      close: function() { 
      allFields.val("").removeClass("ui-state-error"); 
      } }); 

     $("#create-user") .button() .click(function() { $("#dialog-form").dialog("open"); }); 
     }); 
</script> 
<div class="demo"> 

    <div id="dialog-form" title="Create new user"> 
    <p class="validateTips">All form fields are required.</p> 
    <form class="main-form" method="post" action="" enctype="multipart/form-data"> 
     <h3>Fill in some details</h3> 
     <span class="title">Your profile will be submitted with your application:</span><br/> 
     <div class="holder" style="position:relative;top:12px"><a style="color:#24c2c9;" href="></a></div> 
     <br> 
     <span class="title">Why would you be the right candidate?</span><br/> 
     <div class="holder"><textarea class="" name="description" cols="58" rows="10"> </textarea></div> 
     <span class="note"></span> 
     <span class="title">Attachments&nbsp;<a href="#" id="add_attachment" class="plus">&nbsp;</a></span> 
     <div id="attachments" class="holder"></div> 
    </form> 
</div> 

<button id="create-user">Create new user</button> 

<script type="text/javascript"> 
(function() { 
    var counter=1; 
    $("#add_attachment").click(function(e){ 
    e.preventDefault(); 
    var attachmentString = 'attachment-'+counter 
    var inputString = '<input type="file" name="'+attachmentString+'" id="id_'+attachmentString+'" />' 
    $(inputString).appendTo("#attachments") 
    counter = counter+1 
    })})(); 
</script> 
+0

如果您可以在受影响的区域以及脚本中显示代码,也许我们可以了解正在发生的事情。 – ace

+0

感谢您的链接,试图打破一些与重度用户互动的js,但似乎并没有发生。如果这种情况发生在具有所有3个浏览器的单台计算机上,我们可能需要检查ajax请求会发生什么情况以打开对话框。此外,这只会发生在'apply'按钮上,或者也发生在'share'按钮上。 – ace

+0

没有它发生在多台电脑上。一台配XP的旧P4,一台配Windows 7的新笔记本和一台配Kubuntu的上网本。但Ubuntu的情况很奇怪,因为家伙重新启动(为了一些不公开的原因),然后它正在工作....唯一的问题是,当点击应用弹出窗口中的附件时,你会得到一个文件对话框。在某些计算机上,文件对话框不会出现。 –

回答

3

我刚刚经历了这个(OSX,铬),并发现你的问题。因为你没有找到答案,我决定做一些疯狂的事情。 (“input.file”)。live('click',function(element){element.click()});

...这实际上解决了这个问题。请注意,如果你把一个;在click()之后,它会给出一个错误,指出该元素没有click方法。

我不知道这是为什么起作用。这是我实施过的第二次最糟糕的黑客攻击,我对此感到羞耻。有人,请弄清楚这一点,所以我不必在代码中留下这个丑陋,丑陋的黑客。

另请注意,我的输入有'文件'类,因此您可能需要更改选择器以符合您的需求。

1

这没有任何意义,谢谢威廉阁下的解决方案。出于某种原因,我无法评论你的答案。

但是即使没有“;”,我依然会得到没有点击的方法。

后来编辑 没关系,这是一个事件泡沫,一切都为我搞砸了。