Mac1 Posted October 20, 2020 Share Posted October 20, 2020 (edited) Hello, when im disabling IN_DEV mode, my custom loaded JS doesn't work.. What is a reason? I'm loading they in my apps modules and in IN_DEV everything is good. For example: \IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'somthing.js', 'appTest', 'front' ) ); File is located in: appTest>dev>front>somthing.js Edited October 20, 2020 by Mac1 Link to comment Share on other sites More sharing options...
desti Posted October 20, 2020 Share Posted October 20, 2020 Have you forgotten to compile JS? Link to comment Share on other sites More sharing options...
Mac1 Posted October 20, 2020 Author Share Posted October 20, 2020 (edited) 1 minute ago, desti said: Have you forgotten to compile JS? It seems not to work in my case. I'm using it in IN_DEV and remove that mode. JS doesnt work.. Edited October 20, 2020 by Mac1 Link to comment Share on other sites More sharing options...
desti Posted October 20, 2020 Share Posted October 20, 2020 (edited) 49 minutes ago, Mac1 said: appTest>dev>front>somthing.js appTest>dev>js>front>controllers>folder>ips.folder.function.js \IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_folder.js', 'appTest', 'front' ) ); // corrected Edited October 20, 2020 by desti Link to comment Share on other sites More sharing options...
Mac1 Posted October 20, 2020 Author Share Posted October 20, 2020 27 minutes ago, desti said: appTest>dev>js>front>controllers>folder>ips.folder.function.js \IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_folder.js', 'appTest', 'front' ) ); // corrected Wow, i'm trying this but doesn't work. I have pushed JS to Applocation.php in init() and it works, but i don't want to do this that way. Now it looks like: dev/js/front/controllers/shop/ips.shop.something.js \IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'ips.shop.js', 'appTest', 'front' ) ); and every similar combination i tried.. Link to comment Share on other sites More sharing options...
Adriano Faria Posted October 20, 2020 Share Posted October 20, 2020 (edited) Have you registered the controller in your JS and added data-controller to your template? Edited October 20, 2020 by Adriano Faria Link to comment Share on other sites More sharing options...
desti Posted October 20, 2020 Share Posted October 20, 2020 5 minutes ago, Mac1 said: js( 'ips.shop.js', 'appTest', 'front' ) ) 'front_shop.js'. Link to comment Share on other sites More sharing options...
Mac1 Posted October 20, 2020 Author Share Posted October 20, 2020 3 minutes ago, Adriano Faria said: Have you added the data-controller to your JS and to your template? I didn't 1 minute ago, desti said: 'front_shop.js'. Still it doesn't work 😞 Link to comment Share on other sites More sharing options...
Adriano Faria Posted October 20, 2020 Share Posted October 20, 2020 (edited) 5 minutes ago, Mac1 said: I didn't Example I use: JS is on applications/movies/dev/js/front/controllers/movies/ips.movies.submit.js On JS: ;( function($, _, undefined){ "use strict"; ips.controller.register( 'movies.front.movies.submit', { initialize: function() On template: <form accept-charset='utf-8' class="ipsForm {$class}" action="{$action}" method="post" {{if $uploadField}}enctype="multipart/form-data"{{endif}} {{if settings.movies_tmdb_api_key}}data-ipsForm data-controller="movies.front.movies.submit"{{endif}}> On a PHP file (applications/movies/modules/front/movies/submit.php) : \IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_movies.js', 'movies', 'front' ) ); Edited October 20, 2020 by Adriano Faria Link to comment Share on other sites More sharing options...
Mac1 Posted October 20, 2020 Author Share Posted October 20, 2020 Thanks. I'm gonna try it. I don't why IPS made it so complicated.. Link to comment Share on other sites More sharing options...
Mac1 Posted October 20, 2020 Author Share Posted October 20, 2020 (edited) @Adriano Faria but how to name a directory when i'm trying to implement JS in "Profile Extension"? This is not a controller in my case but an extension and "/controllers/" would not work 😞 Edited October 20, 2020 by Mac1 Link to comment Share on other sites More sharing options...
Adriano Faria Posted October 20, 2020 Share Posted October 20, 2020 You can actually give any name. Just register it on JS and use the same in template. Mac1 1 Link to comment Share on other sites More sharing options...
Recommended Posts