Jump to content

After update 1.6.1.6 > 1.6.1.24 Spinning Save Buttons & TypeError typeahead is not a function


Recommended Posts

Alrighty, I tend to never update, because things tend to break. 

Well, I broke this rule and recently updated from 1.6.1.6 to 1.6.1.24 to use a Google Analytics modules that required a newer version. 
Seemingly things went well, but recently my client uncovered an issue when they went to add or edit some products. 

Now when we open a product for editing, we get the persistent Spinning Save buttons that are greyed out, unclickable, and never load. 

There is indeed an error in the developer console, I have attached a copy of that output.

VM1566:5 Uncaught TypeError: $(...).typeahead is not a function
    at HTMLDocument.eval (eval at <anonymous> (jquery-1.11.0.min.js:2), <anonymous>:5:55)
    at j (jquery-1.11.0.min.js:2)
    at Object.add [as done] (jquery-1.11.0.min.js:2)
    at e.fn.init.n.fn.ready (jquery-1.11.0.min.js:2)
    at eval (eval at <anonymous> (jquery-1.11.0.min.js:2), <anonymous>:2:14)
    at eval (<anonymous>)
    at jquery-1.11.0.min.js:2
    at Function.globalEval (jquery-1.11.0.min.js:2)
    at e.fn.init.domManip (jquery-1.11.0.min.js:3)
    at e.fn.init.append (jquery-1.11.0.min.js:3)


So there are already numerous threads on this topic, and I've tried a number of those solutions...changing php versions, small code edits...with no success. 
This particular error seems to be related to either jquery / bootstrap version updates dropping support for typeahead function. 

The most informative piece I found on the subject was by Nemo:
http://nemops.com/spinning-save-button-prestashop-1-6/#.XQKPlhZKiUn

Taking queues from there I'm still having a hard time sorting it out and implementing a solution. 

Any help is appreciated.

Screenshot 2019-06-13 15.40.07.png

Screenshot 2019-06-13 15.45.40.png

Edited by heliumdream
Wrong Previous Version (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...

I think I went about this correctly, at any rate, I got the spinning to stop and I got my save functions working again! (albeit perceivably intermittently, sometimes the save fails for reasons still unknown to me, changes aren't reflected and the same product loads again, instead of getting kicked back to the products page with a green 'Successful update' message.)

Ultimately I edited my /classes/controller/AdminController.php
around line 2644 I added javascript definitions for the functions that were shown to be failing, notably a more recent version of the bootstrap3-typeahead.js file that I tracked down myself, and another for tree.js which the file was already in place but was also throwing bad function calls. 

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

  • 2 weeks later...

Someone requested specific code:
 

        // line2643 - loads specific javascripts for the admin theme
        $this->addJS(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$this->bo_theme.'/js/vendor/bootstrap.min.js');
        $this->addJS(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$this->bo_theme.'/js/vendor/bootstrap3-typeahead.js');
        $this->addJS(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$this->bo_theme.'/js/tree.js');
        $this->addJS(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$this->bo_theme.'/js/vendor/modernizr.min.js');
        $this->addJS(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$this->bo_theme.'/js/modernizr-loads.js');
        $this->addJS(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$this->bo_theme.'/js/vendor/moment-with-langs.min.js');


These are the javascript definitions I added for the functions that were shown to be failing, depending on the errors thrown in your console, your solution may differ. As noted previously, the bootstrap3-typeahead.js file has to be added to the directory manually, it's not already included. 

Edited by heliumdream (see edit history)
  • 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...