Jump to content

Issues with javascript on application


GriefCode

Recommended Posts

Posted

Hey,

im having some trouble that my javascript is not loaded within my applications.
I have tried it now in two ways:

  1. Within the controller action:
    \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('clipboard.js', 'dvstats', 'front'));
    \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('gamelistcopy.js', 'dvstats', 'front'));

     

  2. With a hook:
     

    abstract class dvstats_hook_hookJs extends _HOOK_CLASS_
    {
    
        protected static function baseJs()
        {
            parent::baseJS();
            if ( !\IPS\Request::i()->isAjax() )
            {
                \IPS\Output::i()->jsFiles = array_merge(
                    \IPS\Output::i()->jsFiles,
                    \IPS\Output::i()->js( 'copy.js', 'dvstats', 'front' ),
                    \IPS\Output::i()->js( 'gamelistcopy.js', 'dvstats', 'front' )
                );
            }
        }
    }

     

Does anyone knows why it is not working?
On the developer system it is working without issues. Deploying the application does result that the JS is no longer available.
I'm using cloudflare and purged all cached files.
I have ran the support tool, to clear the cache), but also there, no result.

Any help or ideas would be nice :-)

Posted

You should be using the bundle name, in your case that would be front_copy.js and front_gamelistcopy.js. More information (js is at the bottom):

It works in developer mode because it is automatically loaded from the /dev folder :) 

 

Posted
2 hours ago, Ahmad E. said:

You should be using the bundle name, in your case that would be front_copy.js and front_gamelistcopy.js. More information (js is at the bottom):

It works in developer mode because it is automatically loaded from the /dev folder :) 

 

Thanks for the input, i followed the introduction and have this code now:

        \IPS\Output::i()->jsFiles = array_merge(
            \IPS\Output::i()->jsFiles,
            \IPS\Output::i()->js( 'front_copy.js', 'dvstats', 'front' )
        );

My folder structure looks like this:

Screen Shot 2016-12-17 at 22.27.15.png

But now it does neither load on dev mode nor on the deployed server.

What did i do wrong?

Posted
31 minutes ago, Ahmad E. said:

Your controllers/models folders are missing, check out /core/dev/js/front/ for an example structure. Seems like the JS won't compile unless you use these folders.

Yea that was a reason, thanks for your help.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...