Hassene kh Posted December 10, 2020 Share Posted December 10, 2020 I had created a module prestashop using "extends Module implements WidgetInterface" and i added js file in construct function every things works , when i call a method with ajax a resive an erreur " Uncaught Error: Call to a member function registerJavascript() on null in /var/www/html/PrestaShop-1.7.6.7/modules/ns_monmodule/ns_monmodule.php:54 Stack trace: #0 [internal function]: Ns_MonModule->__construct() #1 /var/www/html/PrestaShop-1.7.6.7/src/Core/Foundation/IoC/Container.php(131): ReflectionClass->newInstance() #2 /var/www/html/PrestaShop-1.7.6.7/src/Core/Foundation/IoC/Container.php(164): PrestaShop\PrestaShop\Core\Foundation\IoC\Container->makeInstanceFromClassName('ns_monmodule', Array) #3 /var/www/html/PrestaShop-1.7.6.7/src/Core/Foundation/IoC/Container.php(177): PrestaShop\PrestaShop\Core\Foundation\IoC\Container->doMake('ns_monmodule', Array) #4 /var/www/html/PrestaShop-1.7.6.7/src/Adapter/ServiceLocator.php(65): PrestaShop\PrestaShop\Core\Foundation\IoC\Container->make('ns_monmodule') #5 /var/www/html/PrestaShop-1.7.6.7/classes/module/Module.php(1141): PrestaShop\PrestaShop\Adapter\ServiceLocator::get('ns_monmodule') #6 /var/www/html/PrestaShop-1.7.6.7/classes/module/Module.php(1120): Modul in <b>/var/www/html/PrestaShop-1.7.6.7/modules/ns_monmodule/ns_monmodule.php</b> on line <b>54</b><br /> " i nedd to konw how to define in the right place and use ajax to call methods from controllers a file js in a module , thanks in advance Link to comment Share on other sites More sharing options...
JBW Posted December 10, 2020 Share Posted December 10, 2020 Add the JS in a hook e.g. hookHeader or hookActionFrontControllerSetMedia and add an if-clause to check the type of controller to load it only when really required. 1 Link to comment Share on other sites More sharing options...
Hassene kh Posted December 10, 2020 Author Share Posted December 10, 2020 Thanks for your reply, i did that and now its solved 🤩 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now