Skip to:
Content
Pages
Categories
Search
Top
Bottom

A step in the right direction making the profile AJAX

  • Avatar of godavid33
    godavid33
    Participant

    @godavid33

    I saw Brajesh’s post, but I thought I’d post some code I made on quickly (but perhaps not elegantly) forcing AJAX behavior in the buddypress profile.

    //Handle link clicks within the buddypress area
    jQuery(‘#buddypress’).on(‘click’, ‘a’, function (event) {
    event.preventDefault();
    //Load with AJAX however you want
    });

    jQuery(‘#buddypress’).on(‘submit’, ‘form’, function (event) {
    event.preventDefault();
    jQuery.post(jQuery(this).attr(‘action’),jQuery(this).serialize(),function(data){
    //Do something on form submit – I.E. load results
    });

    });

    And that’s the bulk of it. I need to figure out how to handle functions that are already ajax (such as clicking the comment on activity button) and dynamically added elements such as the activity submit button (I’m assuming this can probably be handled by loading all script elements from the page).

    Hope that helps some lost soul.

You must be logged in to reply to this topic.