2012-10-12 45 views
1

後,我安裝顏色框形軌道彩盒護欄聯內容

**按照本頁上的說明:http://rubydoc.info/gems/colorbox-rails/0.0.9/file/README.rdoc **這裏的自述說,使用了的link_to

<%= link_to "My superb link", "#", :data => { :colorbox => true } %> 

我什麼將此添加到我的link_to

:data => { :colorbox => true } 

它的工作原理做一個彈出,但我不能把它鏈接到我想要的內容。它將顯示您在彩盒中的頁面或錯誤消息「此內容未能加載」。

我想要在colorbox中獲取聯繫表單。

我運行的Rails 3.2.8

回答

1

<%= link_to "My superb link",show_contact_path(@contact.id), :data => { :colorbox => true } %> 

編輯

你也可以做

// Called directly, without assignment to an element: 
$(".myElement").colorbox({href:"thankyou.html"}); 

// Called directly with HTML 
$(".myElement").colorbox({html:"<h1>Welcome</h1>"}); 

http://www.jacklmoore.com/colorbox

只要確保你的元素class="myElement"

而且如果鏈接是外部創建選擇(信貸一二三)

(即,要超過自己的 應用程序的其他網站) ,您需要按如下方式指定iframe屬性: :colorbox_iframe => true

+0

是否有更簡單的方法?我在想內聯應該更容易一些。與此處的示例類似,請訪問http://www.jacklmoore.com/colorbox/example5/ – gmaniac

+0

感謝您的幫助! – gmaniac

+2

我遇到過這個問題,只是以爲我會給你我1分的解決方案。如果鏈接是外部的(即去除你自己的應用程序的網站),你需要按如下方式指定iframe屬性::colorbox_iframe => true' –