Jump to content

Prestashop 1.7.4.2 products catalog JS error (sortable.js)


Recommended Posts

Hi,

I have just installed fresh version of  PS 1.7.4.2, but I can not remove those default products that prestashop puts on start. When I am in products list page, and press 'remove' either individually or all together - nothing happens.

 

In my JS console I see an error apearing on this page:

TypeError: t.ui is undefined        jquery.ui.sortable.min.js:4:148
TypeError: $(...).modal is not a function      catalog:3465:9
TypeError: $(...).modal is not a function       catalog.js:352:7
 
How is this possible? I have a fresh installation, (just added my module and few things in theme.yml) and the store already breaks?  This sortable is not my script, I beliefe prestashop uses this plugin to display the orders in list. But then why is it already broken? My module doesn't use any sortable - this has to be store plugin that breaks :/
 
Also now I see on 'installed modules' page another JS error (and it's also prestashop's script):
TypeError: $(...).tooltip is not a function     default.js:7:3
Edited by grzegorz123456 (see edit history)
Link to comment
Share on other sites

Ok, I have just found a solution. So for everyone else having this problem:

Apparently prestashop 1.7.4 is very sensitive with the jQuery.  In past I added jQuery in my module, so I am sure my script is loaded after, this way:

  public function hookActionAdminControllerSetMedia($params)
  {
 	 $this->context->controller->addJquery();
 	 $this->context->controller->addJS($this->_path .'assets/css_js/admin.js'); 
   

So removing this $this->context->controller->addJquery()  fixes the problem. No error in console, can remove products.

Jquery is included in Prestashop core.js so basically no need to add it separately again in your module.

Edited by grzegorz123456 (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
  • 4 months later...
On 10/2/2018 at 6:11 PM, Regorro said:

In my JS console I see an error apearing on this page:

TypeError: t.ui is undefined        jquery.ui.sortable.min.js:4:148
TypeError: $(...).modal is not a function      catalog:3465:9
TypeError: $(...).modal is not a function       catalog.js:352:7
 

The $(…).modal is not a function is usually caused because scripts are loaded in the wrong order . The browser will execute the scripts in the order it finds them. If in a script you attempt to access an element that hasn't been reached yet then you will get an error. Make sure that you don't have a script above one that it requires.

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...