Ajax fired twice with custom gloabal.js
-
I’m trying to override the default /_inc/global.js file with a custom one, but after deregister the original one, every post_update is run twice, so each post is duplicated.
I’m using
Wordpress version 4.3
buddypress version 2.3.3
typal-makewp005 Chld themeIn bp-custom.php:
function deregister_bp_scripts(){ wp_deregister_script( 'dtheme-ajax-js'); wp_dequeue_script( 'dtheme-ajax-js'); } add_action('wp_enqueue_scripts', 'deregister_bp_scripts'); function mytheme_enqueue_scripts() { $params = array( 'my_favs' => __( 'My Favorites', 'buddypress' ), 'accepted' => __( 'Accepted', 'buddypress' ), 'rejected' => __( 'Rejected', 'buddypress' ), 'show_all_comments' => __( 'Show all comments for this thread', 'buddypress' ), 'show_x_comments' => __( 'Show all %d comments', 'buddypress' ), 'show_all' => __( 'Show all', 'buddypress' ), 'comments' => __( 'comments', 'buddypress' ), 'close' => __( 'Close', 'buddypress' ), 'view' => __( 'View', 'buddypress' ), 'mark_as_fav' => __( 'Favorite', 'buddypress' ), 'remove_fav' => __( 'Remove Favorite', 'buddypress' ), 'unsaved_changes' => __( 'Your profile has unsaved changes. If you leave the page, the changes will be lost.', 'buddypress' ), ); wp_enqueue_script( 'custom_dtheme-ajax-js', get_stylesheet_directory_uri() . '/js/global.js', array( 'jquery' ) ); wp_localize_script( 'custom_dtheme-ajax-js', 'BP_DTheme', $params ); } add_action('wp_enqueue_scripts', 'mytheme_enqueue_scripts');
I already tried to set different priority , to move this code to functions.php instead of bp-custom.php, to use the twentyfifteen theme, to make a child of the bp-default theme, but no way…
What I need to do is to add some custom fileds to the activity form to create a facebook-like link-preview.I followed this post in which they say you have to add to global.js the new fields’ values, but I don’t want to change the global.js file directly (for next updates)
https://buddypress.org/support/topic/adding-a-second-element-for-posting-with-an-activity/
Does anybody know what am I doing wrong?
- The topic ‘Ajax fired twice with custom gloabal.js’ is closed to new replies.