2012-07-17 74 views
1

是否有可能在控制器上呈現將處於花式框中的視圖的方法?在花式框中顯示RoR視圖

這裏是我的代碼:

<a id="someId" href="#htmlForFancyBox">Open Fancy Box</a> 

    <div style="display: none;"> 
     <div id="htmlForFancyBox"> 
       <!-- html that will be rendered in fancy box --> 
     </div> 
    </div> 

所需的代碼:

# Method on controller that will render view 
    def view_for_fancy_box  

    end 

我知道我需要創建view_for_fancy_box.html.erb文件,將擁有所有的HTML是在顯示:上面沒有div。

如何在花哨的框中實現視圖渲染?

感謝

+0

我猜是的......你試過了什麼? – JFK 2012-07-17 16:50:52

+0

我試圖把所有的shuld去查看到鏈接所在的頁面。然後將其鏈接到通過href鏈接。 – eomeroff 2012-07-17 16:52:56

+0

顯示您的代碼,也許我們可以幫助您 – 2012-07-17 17:01:08

回答

1

對於結構,只需使用此代碼

<script> 
$(document).ready(function(){ 
$("#someId").fancybox({ 
    // API options here 
});//fancybox 
}); // ready 
</script> 

不要忘了加載正確的fancybox JS和CSS文件。

還要確保您添加了版本的權利API選項您使用

如果使用V1.3.4檢查http://fancybox.net/api

對於v2.x檢查http://fancyapps.com/fancybox/#docs

+0

哪一個API是加載視圖到花哨的盒子內容? – eomeroff 2012-07-17 17:30:53

+0

首先只是嘗試它沒有(點擊鏈接到'#htmlForFancyBox') – JFK 2012-07-17 17:46:11