I'm sure there's a better way, but here's one working method by using a custom theme. You need to register the custom theme function in hook_theme(), then disable and re-enable you module to update the theme registry. In your custom theme function, you can rewrite the output HTML, but you'll need to add a different class, 'use-ajax'.
/**
* Implements hook_theme().
*/
function mymodule_theme() {
return array (
'mymodule_link' => array(
'render element' => 'element',
),
);
}
/**
* Returns HTML for a mymodule link
*
* @param $variables
* An associative array containing:
* - element: A render element containing the properties of the link.
*
* @ingroup themeable
*/
function theme_mymodule_link($variables) {
return l(
'<span data-icon="" '.
'aria-hidden="true" class="mymodule-symbol"></span> '.
$variables['element']['#title'],
$variables['element']['#href'],
array(
'html' => TRUE,
'attributes' => array(
'class' => array('use-ajax'),
'title' => $variables['element']['#title']
)
)
);
}
Finally, require the form element to use this theme:
function mymodule_save_progress_link($nid) {
return array(
'#type' => 'link',
'#title' => t('Save Progress'),
'#href' => 'saveprogress/nojs/' . $nid,
'#id' => 'saveprogress-link',
'#ajax' => array(
'wrapper' => 'level-form',
'method' => 'html',
),
'#theme' => 'mymodule_link',
);
}