Jump to content

addJs to my module


Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...