dimanche 1 mars 2015

Javascript event conflict on Wordpress (ET Divi Theme and Buddypress)


I've built a child theme of Divi Theme to use with Buddypress. So far so good, except for a script conflict on commenting buttons.


The theme load a javascript (js/custom.js at 2642:2662) with the following function:



$( 'a[href*=#]:not([href=#])' ).click( function() {
if ( $(this).closest( '.woocommerce-tabs' ).length && $(this).closest( '.tabs' ).length ) {
return false;
}

if ( location.pathname.replace( /^\//,'' ) == this.pathname.replace( /^\//,'' ) && location.hostname == this.hostname ) {
var target = $( this.hash );
target = target.length ? target : $( '[name=' + this.hash.slice(1) +']' );
if ( target.length ) {
et_pb_smooth_scroll( target, false, 800 );

if ( ! $( '#main-header' ).hasClass( 'et-fixed-header' ) && $( 'body' ).hasClass( 'et_fixed_nav' ) && $( window ).width() > 980 ) {
setTimeout(function(){
et_pb_smooth_scroll( target, false, 200);
}, 500 );
}

return false;
}
}
});


This event target the same button that Buddypress use for commenting, preventing AJAX form from loading on click.


enter image description here


I don't want to edit the parent theme (custom.js). How can I prevent this conflict? Is there a workaround, maybe from functions.php?





Aucun commentaire:

Enregistrer un commentaire