Viewing 10 replies - 1 through 10 (of 10 total)
  • Hi,

    I get this too, I’ve let Marcus know about it.

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    Will look into this asap and get back to you. I have a feeling this one is a BP bug…

    Hi,
    just to say, I get the same error (testing BP 1.7)

    I’m also getting the same error. Definitely a conflict between BuddyPress and the Event plugin. Has there been any progress on this or a confirmation? Thanks in advance! ??

    As mentioned here to fix this you need enqueue the autcomplete scripts in the footer by editting the calls to wp_enqueue_script function in file: /wp-content/plugins/buddypress/bp-messages/bp-messages-cssjs.php so it looks like:

    wp_enqueue_script( ‘bp-jquery-autocomplete’, BP_PLUGIN_URL . “bp-messages/js/autocomplete/jquery.autocomplete{$min}.js”, array( ‘jquery’ ), bp_get_version(), true );
    wp_enqueue_script( ‘bp-jquery-autocomplete-fb’, BP_PLUGIN_URL . “bp-messages/js/autocomplete/jquery.autocompletefb{$min}.js”, array(), bp_get_version(), true );
    wp_enqueue_script( ‘bp-jquery-bgiframe’, BP_PLUGIN_URL . “bp-messages/js/autocomplete/jquery.bgiframe{$min}.js”, array(), bp_get_version(), true );
    wp_enqueue_script( ‘bp-jquery-dimensions’, BP_PLUGIN_URL . “bp-messages/js/autocomplete/jquery.dimensions{$min}.js”, array(), bp_get_version(), true );

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    are you still getting this error on 5.5.1? It should have been fixed in 5.5 i think.

    Hie,

    I’ve still this error with BP1.8.1 / EM5.5.1

    Uncaught Error: cannot call methods on autocomplete prior to initialization; attempted to call method

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    this should be fixed in recent updates. works for me.

    I’m wondering if some BP themes are calling these scripts at different parts of your site, because we use this snippet to disable our script on the messages page:

    function bp_em_messages_js_compat() {
    	if(bp_is_messages_compose_screen()){
    		wp_deregister_script( 'events-manager' );
    	}
    }
    add_action( 'wp_print_scripts', 'bp_em_messages_js_compat', 100 );

    Hi Marcus,

    That function is not enough to prevent your script from throwing errors in the WordPress enqueueing process. You need to dequeue the script as well, prior to deregistering. The amended snippet that works for me is:

    function bp_em_messages_js_compat() {
    	if(bp_is_messages_compose_screen()){
    		wp_dequeue_script( 'events-manager' );
    		wp_deregister_script( 'events-manager' );
    	}
    }
    add_action( 'wp_print_scripts', 'bp_em_messages_js_compat', 100 );

    However, I’m still getting the “cannot call methods on autocomplete” error even when the EM script is absent, so I’m not convinced it’s entirely due to EM.

    Cheers, Christian

    I can confirm that the solution posted by e.mont01 works. However, it’s not advisable to edit the BuddyPress plugin files directly, so the following snippet can be used until such time as BuddyPress adopts the change – though given that the default code works on all sites that do not have EM present, I reckon that’s unlikely to happen. Anyway, here’s the code:

    /**
     * Amended copy of messages_add_autocomplete_js()
     */
    function my_messages_add_autocomplete_js() {
    
    	// Include the autocomplete JS for composing a message.
    	if ( bp_is_messages_component() && bp_is_current_action( 'compose' ) ) {
    
    		// ditch previously queued scripts
    		wp_dequeue_script( 'bp-jquery-autocomplete' );
    		wp_dequeue_script( 'bp-jquery-autocomplete-fb' );
    		wp_dequeue_script( 'bp-jquery-bgiframe' );
    		wp_dequeue_script( 'bp-jquery-dimensions' );
    
    		// requeue scripts in footer
    		$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
    		wp_enqueue_script( 'bp-jquery-autocomplete',    BP_PLUGIN_URL . "bp-messages/js/autocomplete/jquery.autocomplete{$min}.js",   array( 'jquery' ), bp_get_version(), true );
    		wp_enqueue_script( 'bp-jquery-autocomplete-fb', BP_PLUGIN_URL . "bp-messages/js/autocomplete/jquery.autocompletefb{$min}.js", array(),           bp_get_version(), true );
    		wp_enqueue_script( 'bp-jquery-bgiframe',        BP_PLUGIN_URL . "bp-messages/js/autocomplete/jquery.bgiframe{$min}.js",       array(),           bp_get_version(), true );
    		wp_enqueue_script( 'bp-jquery-dimensions',      BP_PLUGIN_URL . "bp-messages/js/autocomplete/jquery.dimensions{$min}.js",     array(),           bp_get_version(), true );
    	}
    }
    
    // hook in after BuddyPress
    add_action( 'bp_actions', 'my_messages_add_autocomplete_js', 11 );

    Cheers, Christian

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Auto complete not working in messages’ is closed to new replies.