Matteo97 Posted February 13, 2023 Share Posted February 13, 2023 Hello, i developed a module for Prestashop, i want to add a JS script in the hook "hookAdditionalCustomerAddressFields". It have to work on click of "country" in the address fields. Here is the code i wrote in the main .php file: public function hookAdditionalCustomerAddressFields($params) { $this->context->controller->addJS($this->_path . 'views/js/try.js'); } Here is the js code: $(document).ready(function() { $('select[name="id_country"]').change(function() { console.log("try"); }); }); It Works. The problem is that after changing the country, core.js starts. So by changing the country again my script doesn't work anymore. Any suggestions to "keep alive" my script? Link to comment Share on other sites More sharing options...
idnovate.com Posted February 13, 2023 Share Posted February 13, 2023 Try: $('body').on('change', 'select[name="id_country"]', function() { console.log("try"); }); 1 Link to comment Share on other sites More sharing options...
Matteo97 Posted February 13, 2023 Author Share Posted February 13, 2023 It worked, thank you. 1 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