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).