Attach drupal ajax events to links that were loaded via ajax So I have links that are created when a page first loads that use a render array that is something like this:

array(
    '#type' =&gt; 'link',
    '#title' =&gt; html_entity_decode(t($title)),
    '#href' =&gt; $href,
    '#post_render' =&gt; array('_dva_post_render_ajax_link'),
    '#attributes' =&gt; array(
        'class' =&gt; array('ajax-link'),
        'rel' =&gt; url($href),
    ),
    '#ajax' =&gt; array(
        'path' =&gt; 'dva/ajax/'. $href,
        'wrapper' =&gt; 'content',
        'effect' =&gt; 'fade',
        'prevent' =&gt; 'mousedown',
        'progress' =&gt; array(
        'type' =&gt; 'none',
        'message' =&gt; '',
        ),
    )
);


These all work as expected and properly run the ajax and change the page content, etc.

However, when the page content also includes one of these links, the links included in the ajax response are just normal links and have no ajax functionality. The links are created using this same render array and they render correctly (that is, their markup appears the same as the links that work)

How can I tell Drupal to attach the ajax event handlers to the new links that have just been added to the DOM?
Try using the "use-ajax" class on the link


  In addition to using Form API for doing in-form modification, Ajax may
  be enabled by adding classes to buttons and links. 
  
  By adding the 'use-ajax' class to a link, the link will be loaded via an Ajax call.
  
  When using this method, the href of the link can contain '/nojs/' as
  part of the path. When the Ajax framework makes the request, it will
  convert this to '/ajax/'. 
  
  The server is then able to easily tell if
  this request was made through an actual Ajax request or in a degraded
  state, and respond appropriately.
  
  Source: http://api.drupal.org/api/drupal/includes%21ajax.inc/group/ajax/7


e.g:

array(
    '#type' =&gt; 'link',
    '#title' =&gt; t($title),
    '#href' =&gt; $href,
    '#attributes' =&gt; array(
        'class' =&gt; array('use-ajax'),
        'rel' =&gt; url($href),
    ),
);