I would like to add an action when the user clicks on a Drupal AJAX button.
I tried this code without success:
Drupal.behaviors.myBehavior = {
attach: function (context, settings) {
jQuery('#edit-submit').bind('click', function() {
alert('OK');
});
}
};
The alert is not shown when I click the button (but the AJAX action is done).
The button looks like:
<input type="submit" id="edit-submit" name="op" value="Submit" class="form-submit ajax-processed">
What am I doing wrong?
To solve my problem, I had to use the mousedown event instead of the click event and to print the javascript after any javascript code from Drupal (because it detaches any behaviors from the AJAX elements).