Add elgg.action to href

Hello to all i,ve got this href "href" => "action/friends/add?friend=" . $entity->getGUID(), how do i turn it to something like this "href" => "javascript:elgg.action('friends/add?friend=', { $entity->getGUID() })", to make a Ajax call?

Can someone help me please??



  • Simplest way is to use jquery bindings:

    $(document).on('click', '.link-class', function(e) {


        elgg.action($(this).attr('href'), {

            success: function(result) {

                // do something when the action is complete