Jump to content

why the module js file before jquery.js?


Recommended Posts

59fa9cfaea4af_TIM20171102121826.png.59d86396b8d3817d140e069c41441df4.png

the module js file before the jquery-1.11.0.min.js. so the js error is:

Uncaught ReferenceError: $ is not defined
    at back.js:28

this is my code

public function hookDisplayBackOfficeHeader()
    {
        if (Module::isInstalled($this->name) && Module::isEnabled($this->name) &&
            ($this->context->controller instanceof AdminSplitStatus ||
                $this->context->controller instanceof AdminOrdersController)) {
            $this->context->controller->addJS($this->_path . 'views/js/back.js');
        }
    }

how fix it?

Edited by langziyang (see edit history)
Link to comment
Share on other sites

3 hours ago, langziyang said:

59fa9cfaea4af_TIM20171102121826.png.59d86396b8d3817d140e069c41441df4.png

the module js file before the jquery-1.11.0.min.js. so the js error is:

Uncaught ReferenceError: $ is not defined
    at back.js:28

this is my code


public function hookDisplayBackOfficeHeader()
    {
        if (Module::isInstalled($this->name) && Module::isEnabled($this->name) &&
            ($this->context->controller instanceof AdminSplitStatus ||
                $this->context->controller instanceof AdminOrdersController)) {
            $this->context->controller->addJS($this->_path . 'views/js/back.js');
        }
    }

how fix it?

 

Force to load jQuery before your JS:

 

$this->context->controller->addJquery();

 

  • Like 1
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...