Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Mac1 Posted October 20, 2020 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
Mac1 Posted October 20, 2020 Author 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
desti Posted October 20, 2020 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
Mac1 Posted October 20, 2020 Author 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..
Adriano Faria Posted October 20, 2020 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
desti Posted October 20, 2020 Posted October 20, 2020 5 minutes ago, Mac1 said: js( 'ips.shop.js', 'appTest', 'front' ) ) 'front_shop.js'.
Mac1 Posted October 20, 2020 Author 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 😞
Adriano Faria Posted October 20, 2020 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
Mac1 Posted October 20, 2020 Author Posted October 20, 2020 Thanks. I'm gonna try it. I don't why IPS made it so complicated..
Mac1 Posted October 20, 2020 Author 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
Adriano Faria Posted October 20, 2020 Posted October 20, 2020 You can actually give any name. Just register it on JS and use the same in template. Mac1 1
Recommended Posts