2011-08-17 56 views
0

代碼在視圖頁面笨彈出

HREF = 「#」 類= 「彈出」>車輛詳細

JS文件彈出 (http://preview.hertzci.com/js/core的.js)

變種彈出窗口=函數(){

$$('a.popup').each(function(el){ 

      el.addEvent('click', function(e){ 

        var href = el.href.toString(); 
        href += href.contains("?") ? '&ajax' : '?ajax'; 
        if ($('popup')){ 
          $('popup').destroy(); 
        } 
        var popup = new Element('div', {'id': 'popup'}); 
        var popupInner = new Element('div', {'id': 'popupInner'}).inject(popup); 
        var closeBtn = new Element('a', {'id': 'closeBtn', 'style': 'cursor: pointer'}).inject(popup, 'top'); 
        var myFx = new Fx.Morph(popup, {'duration': 600}); 
        if (el.rel){ 
          rel = el.rel.toString(); 
          xPos = rel.split(",")[0]; 
          yPos = rel.split(",")[1]; 
          myFx.set({'left': xPos, 'top': yPos}); 
        } 
        myFx.set({'opacity': 0}); 
        closeBtn.addEvent('click', function(e){ 
          myFx.start({'opacity': 0}); 
          var e = new Event(e).stop(); 
        }); 
        popup.inject(el.getParent()); 
        // Fetch popup content 
        var req = new Request.HTML({ 
          method: 'get', 
          url: href, 
          data: {}, 
          update: $('popupInner'), 
          onComplete: function(response) { 
            myFx.start({'opacity': 1}); 
          } 
        }).send(); 
        var e = new Event(e).stop(); 
      }); 
    }); 

}

我不得不查看第彈出式菜單中的「popupVehicle.php」的內容 我該怎麼辦?

回答

1

一個可行的方法:

在你的控制文件(注意TRUE,這是該方法的關鍵):

$content = array(); 
$content['popup_content'] = $this->load->view('popupVehicle',array(), TRUE); 
$this->load->view(*your view*, $content); 

在您的視圖文件:

<script type='text/javascript'> 
    /*Place your popup-showing logic here 
     you need to show $('#popup') element*/ 
</script> 
<div id='popup'><? echo $popup_content?></div> 

背後的想法這是將視圖的內容加載到變量中,將該變量傳遞給其他視圖並將其顯示在彈出式元素中。