Any JQX example?

edited July 2011 in Feature Requests
How can I use JQX to load a js file and make it available (ie loaded) inside a backend view displayed using a controller's _render function? Thanks!

Comments

  • edited 4:38PM
    There are 3 main module parameters you can set listed below:
    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).
  • edited 4:38PM
    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...
  • edited July 2011
    [SOLVED]
    Meh... setting

    $vars['js'] = 'yourfile.js'
    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?
  • edited July 2011
    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!
  • edited 4:38PM
    Actually, I believe the latest version of FUEL has a fix similar to that. It was implemented last week or so.
Sign In or Register to comment.