2013-07-02 37 views
1

我用fancybox v2.1.5。
我有一個layout_popup用來加載這些fancybox的內容。兩個fancyboxs的內容是CodeIgniter中的兩個視圖文件。
第1步:從頁面我有一個按鈕來彈出第一個fancybox(類型iframe)。
第2步:從第一個fancybox,我有一個鏈接彈出第二個fancybox(類型iframe)。
我完成了第1步。
請告訴我如何執行第2步! 代碼layout_popup:從第一個fancybox類型的iframe中打開第二個fancybox類型的iframe Codeigniter

<a id="addmore" class="hand-pointer" onclick="add_more();">Add more product...</a> 
<script type="text/javascript"> 
    function CreateFancyBox(selector, url, width, height) { 
     $(selector).fancybox({ 
      'href': url, 
      'titleShow'   : false, 
      'titlePosition'  : 'none', 
      'openEffect'  : 'none', 
      'closeEffect'  : 'none', 
      'openSpeed'   : 'fast', 
      'type'    : 'iframe', 
      'padding'   : 0, 
      'preload'   : true, 
      'width'    : width, 
      'height'   : height, 
      'fitToView'   : false, 
      'autoSize'   : false, 
     }); 
} 
    function add_more() { 
     var url = base_url + 'ctl_product/add_more_product'; 
     CreateFancyBox('a#addmore', url, '50%', 205); 
    }</script> 

從這裏,我點擊 「添加更多的產品...」,彈出第一的fancybox顯示,第一的fancybox的內容(從視圖文件):

<div style="background-color: white;"> 
    <form id="frmAddMoreProd" method="post" action=""> 
     <table id="tblAddMoreProd" cellpadding="0" cellspacing="10" width="100%" border="0"> 
      <tr><th><h3 style="margin-top: 0px;">Add new product</h3></th></tr> 
      <tr> 
       <td>Fill Product Name</td> 
       <td><input class="input-short" style="width: 250px;" type="text" id="prodname" /></td> 
      </tr> 
      <tr> 
       <td></td> 
       <td class="t-right"> 
        <a href="#" class="cancel">Cancel</a> 
        <a id="add_next" class="b-next hand-pointer">Next</a> 
       </td> 
      </tr> 
     </table> 
    </form> 
</div> 

我想當我點擊第一個fancybox內的鏈接「Next」時,彈出顯示的第二個fancybox。代碼包含另一個視圖文件中的第二個fancybox的內容,它的代碼仍然在第一個fancybox的div內。

我該怎麼辦?
我嘗試在layout_popup中插入與腳本相同的js腳本到第一個fancybox中,但我沒有得到任何結果。

+0

。您可以使用第二頁中的方法'parent. $。fancybox.update()'調整fancybox的大小以適應其內容。 – JFK

回答

0

您想要在iframe中打開的視圖實際上是控制器內部的一種方法。您通過構建方法獲得了第一步。對於第二個(iframe)步驟,您只需構建另一個方法並從第一個方法調用第二個方法。我希望我說,以簡單易懂的方式:d
下面是一個例子:如果你正在使用`iframe`模式,內部的fancybox任何鏈接將仍然打開裏面的fancybox

<?php if (!defined('BASEPATH')) die ('No direct script access allowed!'); 

class Custom extends CI_Controller 
{ 
    function first_method() { 
     // my code 
     // ... 
     // echo the first view file 
    } 

    function second_method() { 
     // my code 
     // ... 
     // echo the second view file 
    } 
}