ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Load JS from module

July 26, 2010 1:22pm

Subscribe [2]
  • #1 / Jul 26, 2010 1:22pm

    Eric Barnes

    487 posts

    This is a quick tip because I couldn’t find it in the user guide. If you need to load a javascript file from your module mcp file you can do it like this:

    $this->EE->cp->load_package_js('jsfile');

    Then place your js file in “third_party/module_name/javascript/jsfile.js”.

  • #2 / Jul 26, 2010 1:57pm

    Studio Meta

    105 posts

    Hello Eric, and thanks for sharing.

    I was wondering if you know how to load JS from an extension ?

    Regards,

  • #3 / Jul 26, 2010 4:27pm

    Eric Barnes

    487 posts

    I haven’t started on extensions yet so I am not sure. Maybe someone else can chime in. 😉

  • #4 / Jul 26, 2010 4:57pm

    ender

    1644 posts

    since your function is being called from an extension hook in another part of the codebase, it might just not have the path to the proper package (folder in the third_party directory):

    $this->EE->load->add_package_path(PATH_THIRD . 'your_extension_name/');

    followed by the usual load_package_js() call.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases