Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted October 20, 20204 yr 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, 20204 yr by Mac1
October 20, 20204 yr Author 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, 20204 yr by Mac1
October 20, 20204 yr 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, 20204 yr by desti
October 20, 20204 yr Author 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..
October 20, 20204 yr Have you registered the controller in your JS and added data-controller to your template? Edited October 20, 20204 yr by Adriano Faria
October 20, 20204 yr 5 minutes ago, Mac1 said: js( 'ips.shop.js', 'appTest', 'front' ) ) 'front_shop.js'.
October 20, 20204 yr Author 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 😞
October 20, 20204 yr 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, 20204 yr by Adriano Faria
October 20, 20204 yr Author @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, 20204 yr by Mac1
October 20, 20204 yr You can actually give any name. Just register it on JS and use the same in template.