EllisLab text mark
Advanced Search
     
load view as new window (ie popup)
Posted: 23 September 2007 07:35 AM
Avatar
Joined: 2007-09-15
9 posts

Hi

I’m happy using $this->load->view(‘myview’) in my controller.

I’d like to be able to load a second view at the same time into a new window like a popup ie:

... some code
$this
->load->view('myview');
$this->load->view('popup');   //want in new window
... some more code 

It seems I can’t specify where my view will load. Any ideas on a workaround?

Cheers

Mart

 Signature 

- Mart

 
Posted: 23 September 2007 08:01 AM   [ # 1 ]   [ Rating: 0 ]
Joined: 2006-07-14
4237 posts

It’s not possible to create a popup using php alone. The way i create popups on page load is using the jqModal jquery plugin.

The popup is a div with the class popup. and the code is

$(function(){
 
if($('.popup').length == 1){
   
$('.popup').jqm().jqmShow();
 
}
}
); 

If you really want a new window you could do something like

//controller
$data['popup'$config->site_url().'popup';
$this->load->view('myview',$data);
// view
<?php if(isset($popup))echo '<span id="popup" title="'.$popup.'">'} ?>
// javascript
$(function(){
  
if($('#popup').length == 1){
    
var popupurl = $('#popup').attr('title');
    $(
'#popup').remove();
    
window.open(popupurl);
  
}
}
); 

I’m not so found on popups that do not show their content if there is no javascript.