Clone
3
_insert js
Derek Jones edited this page 2012-07-05 13:58:23 -07:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This may help. It uses Nick Hushers 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) > 0 )
   {
    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; ?>