2011-08-17 10 views
0

コードCodeIgniterのポップアップ

のhref = "#" クラス= "ポップアップ">車両詳細

ポップアップ (のための

のjsファイルhttp://preview.hertzci.com/js/core .js)

VARポップアップ=関数(){

$$('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(); 
      }); 
    }); 

}

iは番目を表示しなければなりませんポップアップの "popupVehicle.php"の内容 どうすればいいですか?

答えて

1

一つの可能​​なアプローチ:あなたのコントローラファイルで

TRUEに注意してください、それはアプローチのキーです):

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

の背後にある考え方:あなたのビューファイルで

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

これはビューの内容を変数にロードし、この変数を他のビューに渡してポップアップ要素に表示することです。