How to add behavior-based onclick to ajax-enabled Form API button? I have a form with a button:

$form['categories_update'] = array(
  '#type' =&gt; 'button',
  '#value' =&gt; t('Load category-related properties'),
  '#ajax' =&gt; array(
    'callback' =&gt; '_mymodule_categories_callback',
    'wrapper' =&gt; 'categories_properties',
    'method' =&gt; 'replace',
    'effect' =&gt; 'fade',
    'prevent' =&gt; 'submit',
  ),
  '#limit_validation_errors' =&gt; array(),
);


Now, in Behavior I'm using:

(function($) { 
  var initialised = false;

  Drupal.behaviors.mymoduleTag = {
    attach: function (context, settings) {

      // Unrelated code

      $('#edit-categories-update', context).on('click', function(){
        console.log('Load category-related prperties clicked');
      });
    }
  };
})(jQuery);


And it simply fails to work - no errors in console, but no code executed either. 

It works all right when I comment out '#ajax' part of a button's definition. Is there a way to have both behavior JS and Form API Ajax working for one button?

I'm using jQuery update module in it's dev version, and I have it set to jQuery 1.8. The button is not inside the wrapper, so it's ID is not affected by AJAX call (verified in browser).
Form API #ajax effectively disables behaviors on elements. I can't see this documented, but that's how it works, consistently. So the solution was to change the line:

$('#edit-categories-update', context).on('click', function(){


and make it

$('#edit-categories-update').ajaxSuccess(function() {


That way code was not executed on click, but after processing of AJAX triggered by the button succeeded. It's not useful if you want to perform JavaScript before AJAX call, but if you need it to happen after, or if you don't care, it is a sufficient solution. If you need things to happen before AJAX call, use this instead:

$('#edit-categories-update').ajaxStart(function() {