(function($) {
Drupal.subscribeAjax = {
form_id: 'webform-client-form-34' // your webform id
};
Drupal.behaviors.subscribeAjax = {
attach: function(context, settings) {
// Extend Drupal.ajax object
for (ajax_el in settings.ajax) {
if (typeof Drupal.ajax[ajax_el] != 'undefined' && Drupal.ajax[ajax_el].element.form) {
if (Drupal.ajax[ajax_el].element.form.id === Drupal.subscribeAjax.form_id) {
Drupal.ajax[ajax_el].beforeSend = Drupal.subscribeAjax.beforeSend;
Drupal.ajax[ajax_el].success = Drupal.subscribeAjax.success;
Drupal.ajax[ajax_el].error = Drupal.subscribeAjax.error;
}
}
}
}
};
Drupal.subscribeAjax.beforeSend = function(first, second) {
console.log("before submit");
Drupal.ajax.prototype.beforeSend.call(this, first, second);
}
Drupal.subscribeAjax.success = function(response, status) {
console.log("on success");
//console.log(JSON.stringify(response));
Drupal.ajax.prototype.success.call(this, response, status);
}
Drupal.subscribeAjax.error = function(response, uri) {
console.log("on error");
Drupal.subscribeAjax.enableForm(this.element.form);
Drupal.ajax.prototype.error.call(this, response, uri);
}
})(jQuery);
// ajaxComplete
(function($) {
$(document).ajaxComplete(function(event, xhr, options) {
var data = $.httpData(xhr,options.dataType);
//console.log(JSON.stringify(data));
$('#webform-ajax-wrapper-34 .error').delay(5000).fadeOut(400);
});
}(jQuery));
Drupal.subscribeAjax = {
form_id: 'webform-client-form-34' // your webform id
};
Drupal.behaviors.subscribeAjax = {
attach: function(context, settings) {
// Extend Drupal.ajax object
for (ajax_el in settings.ajax) {
if (typeof Drupal.ajax[ajax_el] != 'undefined' && Drupal.ajax[ajax_el].element.form) {
if (Drupal.ajax[ajax_el].element.form.id === Drupal.subscribeAjax.form_id) {
Drupal.ajax[ajax_el].beforeSend = Drupal.subscribeAjax.beforeSend;
Drupal.ajax[ajax_el].success = Drupal.subscribeAjax.success;
Drupal.ajax[ajax_el].error = Drupal.subscribeAjax.error;
}
}
}
}
};
Drupal.subscribeAjax.beforeSend = function(first, second) {
console.log("before submit");
Drupal.ajax.prototype.beforeSend.call(this, first, second);
}
Drupal.subscribeAjax.success = function(response, status) {
console.log("on success");
//console.log(JSON.stringify(response));
Drupal.ajax.prototype.success.call(this, response, status);
}
Drupal.subscribeAjax.error = function(response, uri) {
console.log("on error");
Drupal.subscribeAjax.enableForm(this.element.form);
Drupal.ajax.prototype.error.call(this, response, uri);
}
})(jQuery);
// ajaxComplete
(function($) {
$(document).ajaxComplete(function(event, xhr, options) {
var data = $.httpData(xhr,options.dataType);
//console.log(JSON.stringify(data));
$('#webform-ajax-wrapper-34 .error').delay(5000).fadeOut(400);
});
}(jQuery));
ፈ
ReplyDelete(y)
Delete