Bind click event to ajaxify form button how the title says I would like to trigger javascript (jQuery) event from generated Drupal form button. I already add an id to the button and added the javascript in theme file like so: 

$form['dialogCreateButton'] = array(
    '#type' =&gt; 'button', 
    '#value' =&gt; t('Create'),
    '#ajax' =&gt; array(
        'callback' =&gt; 'form_kalendar_dialog_validate',
        'progress' =&gt; array(
            'type' =&gt; 'throbber', // needs to be defined
            'message' =&gt; t("Please wait..."), // instead of a message insert a javascript
        ),
    ),
);


and the javascript:

jQuery("#edit-dialogsavebutton").bind('click',function(event) {
    if(jQuery("#dialog-event-title").val().length == 0){
        focusElement.children("#eventTitle").text('(No title)');
    }else{
        focusElement.children("#eventTitle").text( jQuery("#dialog-event-title").val() );
    }
    jQuery('#dialog').dialog('close');
});


also with Drupal js:

Drupal.behaviors.rr = {

    attach: function(context, settings) {
        jQuery('#form-kalendar-dialog').once().ajaxComplete(function(event, xhr, settings) {
            console.log( event );
        });
    }
}


Only after several clicks the event is triggered, it acts very strange...
Ajax callback function must to have an ajax_command_invoke function witch trigger an custom made function in JS side like so:

function form_kalendar_dialog_validate($form, &amp;$form_state) {
  $commands = array();
  $commands[] = ajax_command_invoke(NULL, 'customMethod', array('Custom Method Arg.'));
  return array('#type' =&gt; 'ajax', '#commands' =&gt; $commands);
}


JS

(function ($) {
  $.fn.customMethod = function(arg) {
    // Custom JS goes here.
    console.write(arg);
  };
}) (jQuery);


The answer whas here: Tlattimore blog