[eluser]pickupman[/eluser]
I do this by having a $custom_js tag in the head of my template/views. Then I use:
Code:
$data['custom_js'] = 'function displayData(){'; //rest of js function
//or
$data['custom_js'] = $this->load->view('custom_js_view', $data, TRUE); //place code in /views/custom_js_view.php file
The latter method could allow to write a method to lookup a view based on controller/method. I usually create a subfolder in the views folder named the same as the controller. Say you create a js subfolder in each of those folders. Then you could write a function to see if a custom_js view exists, and if so load it.