Created
May 14, 2014 08:15
-
-
Save ThomasHambach/467f3b6376f097bde024 to your computer and use it in GitHub Desktop.
Drupal 7 Execute custom function when doing AJAX load
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
Drupal.behaviors.contact = { | |
attach: function (context, settings) { | |
$('.webform-client-form input').attr('readonly', false); | |
// Actions are stored in Drupal.ajax, every ajax call these identifiers might change. | |
$.each(Drupal.ajax, function(k, v) { | |
if(k.match(/edit-submitted-about/g)) { // The identifier I was aiming for was prefixed with "edit-submitted-about". | |
Drupal.ajax[k].options.beforeSerialize = function(element, options) { | |
Drupal.ajax.prototype.beforeSerialize(element, options); | |
$('.webform-client-form input').attr('readonly', true); | |
} | |
} | |
}); | |
}; | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment