Part of the EllisLab Network
x
 
Create New Page
 View Previous Changes    ( Last updated by thinkigniter )

insert js

This may help.
It uses Nick Husher’s assets management idea and is set to jun jquery, you can change that.

if ( ! function_exists('_insert_js')){    
  
function _insert_js$JQ 'unknown'$debug FALSE ){
    $js 
= array();
    
$js[] '[removed][removed]';
   if( 
is_array($JQ) and count($JQ) > )
   
{
    
foreach( $JQ  as $script  ){
     $js[] 
'[removed][removed]';
    
}
  }
  ob_start
();
  echo 
"\r\n";
  foreach( 
$js as $line ){
  
echo $line "\r\n";
  
}
  
return ob_get_clean();
  
}

In my controller I use…

$initialize_js _insert_js( array('/scripts/my_other_script.js') );
$this->load->view('my_view',$initialize_js); 

and in my view…

<?php echo $initialize_js?>