Jump to content

Override javascript file


gnoma
 Share

Recommended Posts

Hi guys :) First of all, sorry for my English.

 

I have unsuccessfully been looking for a solution to my problem.

 

I'm developing a module which overrides an admin controller class. The base controller loads a javascript file, let's say /js/foo.js, through $this->addJS(_PS_JS_DIR_.'foo.js') which is ok. But the point is I also need to override that javascript file. Placing a newly created js file in /override/js/foo.js takes no effect.

 

Is it possible to override a JavaScript file?

 

I'm opened to other solutions, i.e. directly adding a custom js file, but the only way I can figure out is by hardcoding the URL (which of course is not ok). How can a module js file be loaded by a overridden controller without hardcoding its path?

 

Thanks a lot.

Share this post


Link to post
Share on other sites

  • 3 months later...

Hello there,

 

I have the same problem. I've tried to locate the file in many places (inside the theme, in the override folder, etc.) but I can't make it work.

 

Any idea of how to override a js file located in /js folder?

 

Thanks in advance.

Edited by elvizgz (see edit history)

Share this post


Link to post
Share on other sites

Hi gnoma,

 

are you developing a module or an override?

As far as I know, if it's a module you have to put all the js files required under %root%/modules/my_module/js/ or %root%/themes/(default or)my_theme/modules/my_module/js/ in case you are overriding an existing module :)

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More