2014-03-24 44 views
0

我似乎無法讓我的模態工作。我可以看到透明覆蓋層,但就是這樣。內容在<div>中,但不會以屏幕上的模式格式顯示。這是我的代碼。有沒有人有任何想法?無法讓Twitter Bootstrap模式正常工作

這裏是我的HTML:

<a href="#modal-[nid]" class="ajax-link" data-nid="[nid]" 
    data-toggle="modal" data-target="#modal-[nid]">[title]</a> 
<div id="modal-[nid]" class="modal hide" tabindex="-1" role="dialog"> 
    <div class="modal-body"> 
     <button type="button" class="close" data-dismiss="modal" 
      aria-hidden="true">×</button> 
     <span>this is a test of my modal</span> 
    </div> 
</div> 

我從來沒有嘗試過實施這樣的事。我已經加載了引導CSS文件和JS文件。有沒有人有任何想法,我錯了?

---編輯---

我的退出按鈕不工作,並期待這樣的:

enter image description here

它似乎並沒有被裝載在html按鈕...只顯示一個x,並且周圍沒有<button>標籤。

+0

你有一個工作環境,我們可以看到什麼?這有點像說我的汽車不會啓動,但它有汽油在其中... – Richlewis

+1

參考 - > http://getbootstrap.com/javascript/#modals或在http:// bootply上對代碼進行工作演示.com – rockStar

+0

我假設上面的代碼是一個模板文件,並且[nid]正在被您的活網站上的變量替換?你有沒有嘗試用靜態名稱暫時替換[nid]並查看它是否有效?您還錯過了很多引導文檔在模式示例中顯示的HTML。我不確定需要多少,但可能會先嚐試複製其代碼,看看是否可以使其工作:http://getbootstrap.com/javascript/#modals –

回答

1

你有一些錯誤。取出hide類。包裹身體一modal-content內和內modal-dialog

<a href="#modal-1" class="ajax-link" data-nid="[nid]" data-toggle="modal" data-target="#modal-1">[title]</a> 
    <div id="modal-1" class="modal" tabindex="-1" role="dialog"> 
    <div class="modal-dialog"> 
     <div class="modal-content"> 
     <div class="modal-body"> 
      <button type="button" class="close" data-dismiss="modal" 
      aria-hidden="true">×</button> 
      <span>this is a test of my modal</span> 
     </div> 
    </div> 
    </div> 
</div> 

http://www.bootply.com/124339

+0

這似乎確實可以顯示模式。但是那個密集的布丁似乎不起作用。我用一張關於正在發生的事情的圖片更新了我的問題。無論如何,我想完全將'x'按鈕更改爲圖片。你會碰巧對我需要添加什麼類或屬性來完成這個任何想法嗎? – scapegoat17