Q:

How to add behavior-based onclick to ajax-enabled Form API button?

I have a form with a button:
$form['categories_update'] = array(
  '#type' => 'button',
  '#value' => t('Load category-related properties'),
  '#ajax' => array(
    'callback' => '_mymodule_categories_callback',
    'wrapper' => 'categories_properties',
    'method' => 'replace',
    'effect' => 'fade',
    'prevent' => 'submit',
  ),
  '#limit_validation_errors' => 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).

A:

I've done this by creating a function in the js file and then calling the function using the Drupal ajax_command_invoke() function.
For example, in the js put this:
$.fn.yourmodule_somename = function() {
  console.log('Load category-related prperties clicked');
}

And then in the AJAX callback, put this to call that function:
$commands[] = ajax_command_invoke(NULL, 'yourmodule_somename');

