Jump to content
lozitax

fichier JavaScript dans un controller

Recommended Posts

Bonsoir,

J'aimerais charger un fichier JS dans un controller, mais quand je met le code :

$this->context->controller->addJS($this->_path.'views/js/accordeon.js');

j'obtiens cette erreur :

Notice: Trying to get property 'controller' of non-object

Si quelqu'un à la solution je suis preneur

Merci beaucoup :D

Share this post


Link to post
Share on other sites

Euh... vous êtes déjà dans le contrôleur^^

Share this post


Link to post
Share on other sites

Enfaite je débute donc je galère un peu mdrr...

Ducoup je dois mettre quel code ?

 

Share this post


Link to post
Share on other sites

    public function setMedia()
    {
        parent::setMedia();
        $this->addJS(_THEME_JS_DIR_.'accordeon.js');
    }

suffit ;) 

($this->_path c'est pour les modules pas pour les controleurs^^)

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

×
×
  • Create New...

Important Information

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