Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 UTC on 18 March 2024, to get $100 off your ticket.
Hi,
If a user selects several books quickly, the ajax content is returned from the first request, not the last and causes the wrong parent item to be displayed. Also if they hit Save before the ajax request completes an illegal choice error will also occur. I have created some jquery that fixes this issue.
Drupal.behaviors.bookDisableAjaxStarted = {
attach: function (context, settings) {
jQuery(".book-title-select").each(function() {
var self=this;
jQuery(self).change(function() {
setTimeout(function(){
disableSubmitting();
jQuery(self).attr("disabled","disabled");
jQuery(self).css({ opacity: 0.5 });
}, 10);
setTimeout(function(){
enableSubmitting();
jQuery(self).removeAttr("disabled");
jQuery(self).css({ opacity: 1.0 });
}, 2000);
});
});
}
};
Drupal.behaviors.bookDisableAjaxFinished = {
attach: function (context, settings) {
jQuery(".book-title-select").each(function() {
jQuery(this, context).once("DOMSubtreeModified", function () {
for (var property in context) {
if(property=="ready"){
enableSubmitting();
jQuery("#edit-book-bid").removeAttr("disabled");
jQuery("#edit-book-bid").css({ opacity: 1.0 });
}
}
});
});
}
};
function disableSubmitting(){
jQuery("#edit-submit").attr("disabled","disabled");
jQuery("#edit-preview").attr("disabled","disabled");
jQuery("#edit-delete").attr("disabled","disabled");
jQuery("#edit-preview-changes").attr("disabled","disabled");
jQuery("#edit-submit").css({ opacity: 0.5 });
jQuery("#edit-preview").css({ opacity: 0.5 });
jQuery("#edit-delete").css({ opacity: 0.5 });
jQuery("#edit-preview-changes").css({ opacity: 0.5 });
jQuery("*").css("cursor", "progress");
}
function enableSubmitting(){
jQuery("#edit-submit").removeAttr("disabled");
jQuery("#edit-preview").removeAttr("disabled");
jQuery("#edit-delete").removeAttr("disabled");
jQuery("#edit-preview-changes").removeAttr("disabled");
jQuery("#edit-submit").css({ opacity: 1.0 });
jQuery("#edit-preview").css({ opacity: 1.0 });
jQuery("#edit-delete").css({ opacity: 1.0 });
jQuery("#edit-preview-changes").css({ opacity: 1.0 });
jQuery("*").css("cursor", "auto")
}
Comments