WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Auto complete not working in messages (11 posts)

  1. Kiran@Caret
    Member
    Posted 1 year ago #

    When i am composing message to my friends from buddypress the auto complete is not working showing my suggestion of my friends.

    Getting this error in BuddyPress 1.6.4, when using chrome console.

    "Uncaught Error: cannot call methods on autocomplete prior to initialization; attempted to call method 'http://something.com/wp-admin/admin-ajax.php' "

    When de-activate the event manager plugin auto complete works.
    Can you look into this issue.

    When i install Events Manager 5.3.2 the auto-complete works.

    Thanks for the sharing this awesome plugin.

    http://wordpress.org/extend/plugins/events-manager/

  2. agelonwl
    Member
    Posted 1 year ago #

    Hi,

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

  3. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

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

  4. stefwilliams
    Member
    Posted 1 year ago #

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

  5. David Bisset
    Member
    Posted 10 months ago #

    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! :)

  6. e.mont01
    Member
    Posted 10 months ago #

    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 );

  7. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 10 months ago #

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

  8. geoffroycochard
    Member
    Posted 10 months ago #

    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

  9. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 10 months ago #

    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 );
  10. Christian Wach
    Member
    Posted 8 months ago #

    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

  11. Christian Wach
    Member
    Posted 8 months ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic