• Resolved manoskav

    (@manoskav)


    I have the following error in my console causing several problems (e.g. drop down menu is not working on hover).

    Uncaught TypeError: jQuery(…).select2 is not a function
    at HTMLDocument.<anonymous> (um-scripts.min.js?ver=dd6fc7c9f966f21a57e2189aa5ab80f9:1)
    at i (jquery.js?ver=1.12.4:2)
    at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4:2)
    at Function.ready (jquery.js?ver=1.12.4:2)
    at HTMLDocument.K (jquery.js?ver=1.12.4:2)

    If i delete the function select2 from the file /wp-content/plugins/ultimate-member/assets/js/um-scripts.min.js everything is ok (until the next update…)

    Any ideas please?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi!

    Got same problem on “Shop” page, when installed UM on site with WooCommerce.

    Seems for some reason UM does not includes JQuery Select2 library.

    I’ve added this line in my plugin code and it solved the issue:

    wp_enqueue_script( ‘select2-js’, ‘https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js&#8217;, array(), ‘4.0.6’, true );

    • This reply was modified 6 years, 1 month ago by alexitpro.
    Thread Starter manoskav

    (@manoskav)

    Thank you @alexitpro
    Can you tell me in which file did you add this piece of code?

    @manoskav I use my own plugin, which is active all time and put code there.
    In general, I guess you can put this line of code in your WP active theme’s file functions.php

    Thread Starter manoskav

    (@manoskav)

    Thanks a lot! I ‘ll give it a try and let the community know ??

    @manoskav welcome and please comment the result! ??

    Thread Starter manoskav

    (@manoskav)

    Hi all,

    I pasted that code in my theme’s functions.php, and now everything is ok. No errors in console.

    HINT: if you use cPanel editor (and maybe other editors), change the ‘ character, otherwise you will get a syntax error.

    @alexitpro thanks again ??

    @manoskav thank you for your comment. I would recommend use more functional IDE like NetBeans, PHP Storm, Visual Studio Code. These tools will help you if you forgot part of php syntax like difference between ‘ ” ` ‘ quote symbols (juniors mainly are confused ?? )

    Had the same problem but I found a solution to it. Basically what UM does is if class_exists(“WooCoommerce”) it dequeues select2 both style and script. There is a hook called “um_dequeue_select2_scripts” to remove the select2 that UM adds but that works only partially as the case for this to work is actually this one:

    $dequeue_select2_status = apply_filters(“um_dequeue_select2_scripts”, false);
    if(class_exists(“WooCoommerce”) || $dequeue_select2_status)

    This means that you cannot really force it to be removed if you have woocommerce active. What you can do is deregister and dequeue select2 and then re-enqueue one for the woocommerce as a solution for now. That will bring both functionality and style of the default woo. Also make sure that your “wp_enqueue_scripts” is above priority of 100 as theirs is 100.

    Hope it will help someone.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Problem with select2 function’ is closed to new replies.