Change 'href' attribute in AJAX enabled links I have some links with the class use-ajax. Everything works fine with default settings.

The problem is that at some point I need to change the href attribute of a link and make the ajax call to the new url, which is not working. The call is made to the initial url of that link.

I tried to reattach behaviours but this doesn't seem to work.

Any help would be appreciated.

Any ideas? Thanks
Drupal link based Ajax, correspond to a Drupal.ajax['#id'] element object and drupal works with them not with DOM Objects.

So you don't have to change the href attribute you need to change the URL where it's doing POST in the Drupal.ajax element, in this case do this:

// Confirm structure first executing on console 'Drupal.ajax['#id'].options.url'
var href = 'hook_url/ajax/parameter1/parameter2';

// And change the href POST parameter
Drupal.ajax['#id'].options.url = href;


And it's done!