As an example, as a default, the "js_controller_path" is set to look in the folder /daylight/FUEL/v.9/fuel/modules/fuel/assets/js/fuel/controller/
For the "js_controller" parameter, their is a default "BaseFuelController" javascript file that gets loaded unless that parameter is set to something else (e.g. /daylight/FUEL/v.9/fuel/modules/fuel/assets/js/fuel/controller/BaseFuelController.js)
For the "js_controller_params" those are values that get passed to the controller in an "initObj" object (simple JSON object)
I would look at the /daylight/FUEL/v.9/fuel/modules/fuel/assets/js/fuel/controller/PageController.js file as an example. It inherits from the BaseFuelController, and although it's commented out in the top, it shows how it can load a jquery plugin from within the same file (this allows you to keep all your javascript in one spot).
Ok sorry, what i really meant is how to load a javascript file from a module's controller (if that makes any sense) and push this file to the list of files the rendered view will load...
does indeed work. I was looking at the wrong page :S Sorry!! i see the backend's header responsible for the loading of assets is modules/fuel/views/_blocks/fuel_header.php and that at line 17 it does a nice
<?php if (!empty($js)) { echo js($js); } ?>
But setting $vars['js'] inside the controller that does the _render() won't have any effect... don't really get why
[EDIT] here's why:
at lines 212/214 in Fuel_base_controller.php $vars is only passed to the view and not the other blocks
I've gone ahead and took the liberty to add a fix inside the fuel_header block at line 17, and changed
echo js($js);
to
# Fix by Pierlo: add support for module's JS if (!empty($js)) { if (!is_array($js)) echo js($js); else foreach($js as $file => $module) echo js($file, $module); }
Like this when you set the $vars['js'] in your controller you have the option to make it an array of 'file' => 'module' pairs and this will include the js file from the module's assets/js folder. Not sure if this is the right way to achieve this, but i can't really wrap my head around the JQX framework yet :P I thought this might help others... @admin if there's anything wrong with this approach let me know!
Comments
js_controller_path
js_controller
js_controller_params
More descriptions about those parameters can be found here:
http://www.getfuelcms.com/user_guide/modules/simple
As an example, as a default, the "js_controller_path" is set to look in the folder
/daylight/FUEL/v.9/fuel/modules/fuel/assets/js/fuel/controller/
For the "js_controller" parameter, their is a default "BaseFuelController" javascript file that gets loaded unless that parameter is set to something else (e.g. /daylight/FUEL/v.9/fuel/modules/fuel/assets/js/fuel/controller/BaseFuelController.js)
For the "js_controller_params" those are values that get passed to the controller in an "initObj" object (simple JSON object)
I would look at the /daylight/FUEL/v.9/fuel/modules/fuel/assets/js/fuel/controller/PageController.js file as an example. It inherits from the BaseFuelController, and although it's commented out in the top, it shows how it can load a jquery plugin from within the same file (this allows you to keep all your javascript in one spot).
Meh... setting does indeed work. I was looking at the wrong page :S
Sorry!!
i see the backend's header responsible for the loading of assets is modules/fuel/views/_blocks/fuel_header.php and that at line 17 it does a nice
<?php if (!empty($js)) { echo js($js); } ?>
But setting $vars['js'] inside the controller that does the _render() won't have any effect... don't really get why
[EDIT] here's why:
at lines 212/214 in Fuel_base_controller.php $vars is only passed to the view and not the other blocks
$this->load->module_view(FUEL_FOLDER, '_blocks/fuel_header');
$this->load->module_view($module, $view, $vars);
$this->load->module_view(FUEL_FOLDER, '_blocks/fuel_footer');
Not sure I understand why this is so. How can I set the js var to be read by the header block?
and changed to Like this when you set the $vars['js'] in your controller you have the option to make it an array of 'file' => 'module' pairs and this will include the js file from the module's assets/js folder. Not sure if this is the right way to achieve this, but i can't really wrap my head around the JQX framework yet :P
I thought this might help others...
@admin if there's anything wrong with this approach let me know!