Support » Fixing WordPress » JQuery: "is not a function" error

  • Resolved PeterC66

    (@peterc66)


    I have only a smattering of javascript, and do not know Jquery, so do not know how to solve what must be an easy problem.

    I am using WordPress integrated with another system – TNG (The Next Generation of Genealogy Sitebuilding). On TNG/WordPress pages I am getting an “Uncaught TypeError: undefined is not a function” javascript message on code related to two plugins (Tippy and Wp cycle text announcement). See for example http://www.hcnhistory.org.uk/blank-for-people/relateform.php?primaryID=I11157&tree=hcn

    One of the places the error occurs is the third line of:

    <script type="text/javascript">
                    jQuery(document).ready(function() {
                        jQuery('.tippy').tippy({ position: "link", offsetx: 0, offsety: 10, closetext: "X", hidedelay: 700, showdelay: 100, calcpos: "parent", showspeed: 200, hidespeed: 200, showtitle: true, hoverpopup: true, draggable: true, dragheader: true, multitip: false, autoshow: false, showheader: true, showclose: true, htmlentities: false });
                    });
                </script>

    Exactly the same code appears in plain WordPress pages (e.g. http://www.hcnhistory.org.uk/ ) and I get no error.

    One strategy I am adopting is to try to turn off the plugins when in the TNG pages, but I am having a problem doing that. Is there another way of preventing the error happening?

    Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Where are you placing that code? Looking closely it appears before the jquery file is loaded. Are you enqueuing it properly?

    Thread Starter PeterC66

    (@peterc66)

    Thanks for such a prompt response.

    I am doing very little coding – it is all plugins. And until I Googled it just now I didn’t know what enqueuing is!

    Using the Chrome tool to examine http://www.hcnhistory.org.uk/ (a page without the error) I can see lines 60 and 61 are

    <script type='text/javascript' src='http://www.hcnhistory.org.uk/wp/wp-includes/js/jquery/jquery.js?ver=1.11.0'></script>
    <script type='text/javascript' src='http://www.hcnhistory.org.uk/wp/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.2.1'></script>

    and the code I quoted before is at line 112. Does this mean that the jquery file is loaded before where it is needed?

    Looking at http://www.hcnhistory.org.uk/blank-for-people/relateform.php?primaryID=I11157&tree=hcn (a page that errors), at lines 59 and 60 I see

    <script type='text/javascript' src='http://www.hcnhistory.org.uk/wp/wp-includes/js/jquery/jquery.js?ver=1.11.0'></script>
    <script type='text/javascript' src='http://www.hcnhistory.org.uk/wp/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.2.1'></script>

    and the code I quoted before that has the error marked is at line 110.
    I have used WinMerge on the two html files and see that at these locations they are identical. Is it possible that jquery has not been loaded in this case?

    Thanks again.

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Looking closer the one with the two errors appears to be loading two versions jQuery. The one bundled with WordPress and the second one from Google.

    Thread Starter PeterC66

    (@peterc66)

    Thanks. I can see that now. The googleapis one is needed by the TNG plugin, and the one bundled with WordPress is needed by the plugins. This might help to explain some other odd things happening in my TNG pages.

    This could be tricky. I see a way of dealing with it at http://conceptf1.blogspot.co.uk/2013/12/conflict-in-multiple-jquery-files-on-same-page.html and http://www.zirev.com/2013/03/how-to-use-multiple-jquery-on-same-page.html#.U6UglPldXTA but I would need to alter the coding within the WP plugins. (I would not want to amend the TNG system as jquery is used in thousands of places.)

    Maybe my cleaner option is to try to disable the plugins when on the TNG pages. I am trying to do that using Plugin Organizer, but am having a problem getting it to do what I need. The author is being very helpful, and I am hopeful.

    Any other ideas are welcome.

    Thread Starter PeterC66

    (@peterc66)

    Issue solved by developing a simple Must Use plugin for disabling most plugins on TNG screens.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘JQuery: "is not a function" error’ is closed to new replies.