GriefCode Posted December 17, 2016 Posted December 17, 2016 Hey, im having some trouble that my javascript is not loaded within my applications. I have tried it now in two ways: 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')); 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 :-)
Ahmad E. Posted December 17, 2016 Posted December 17, 2016 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
GriefCode Posted December 17, 2016 Author Posted December 17, 2016 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: But now it does neither load on dev mode nor on the deployed server. What did i do wrong?
Ahmad E. Posted December 17, 2016 Posted December 17, 2016 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.
GriefCode Posted December 17, 2016 Author Posted December 17, 2016 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.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.