Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted December 17, 20168 yr 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 :-)
December 17, 20168 yr 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
December 17, 20168 yr Author 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?
December 17, 20168 yr 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.
December 17, 20168 yr Author 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.