2013-02-25 60 views
4

使用時,我有引導有點怪異的問題,文件域文件輸入字段忽略的點擊。引導:在模態對話框

http://jsfiddle.net/RxxSv/4/

只要我添加data-toggle="modal"的模式容納,文件輸入字段停止反應,點擊(瀏覽器不會顯示文件選擇對話框)。

我懷疑這是由Bootstrap的模態代碼/事件處理引起的。點擊事件正在消失,但我無法真正弄清楚。

任何想法?

回答

5

我無法真正解釋爲什麼,但如果您將documentation(在實時演示)中的所有屬性都設置爲正確,則輸入正常工作。

<div id="modal-upload" class="modal hide fade" tabindex="-1" 
role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 

的jsfiddle:http://jsfiddle.net/4TQvY/

+1

感謝暗示。根據你的回答做了更多的研究之後,我發現'data-toggle =「modal」'甚至不應該在模態容器中。這應該在切換模式的按鈕上。我不知道它如何在容器中結束,但它肯定是我的錯。 tl; dr:刪除'data-toggle'屬性。 – BastiBen 2013-02-26 00:13:16

+0

數據切換屬性導致我適合,謝謝badcat – 2013-11-15 16:59:33

0

我的同志勸做另一種說法:

<a class="btn btn-primary" href="#" style="margin-left: 100px" id="prefix">Choose file</a><input type="file" id="file_source" style="position:absolute;z-index:2;top:0;left:0;filter:alpha(opacity=0);opacity:0;background-color:transparent;color:transparent;"> 

使分開的&輸入,然後調用點擊事件

jQuery("#prefix").click(function() 
    { 
     console.log("INSERT JSON"); 
     $("#file_source").click(); 
     return false; 
    });