This is a regression from the original AJAX system in CTools.
The throbber is placed on the item in 'beforeSubmit'. However, that before function only runs on form submissions. It does not run on normal $.ajax calls. For those, you need to use beforeSend, which is always called.
beforeSubmit is really only interesting if you intend to modify the form values, which the current beforeSubmit does not do. Therefore, we need to change the beforeSubmit we currently use to before Send. However, to maintain the easy ability to add functionality to beforeSend, we should retain an empty function.
Patch forthcoming.
Comment | File | Size | Author |
---|---|---|---|
#11 | 969346-before-submit-should-be-before-send.patch | 2.86 KB | merlinofchaos |
#10 | drupal.ajax-options-throbber.10.patch | 3.49 KB | sun |
#1 | 969346-before-submit-should-be-before-send.patch | 2.24 KB | merlinofchaos |
Comments
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedHere is the aforementioned patch.
Comment #2
rfaysubscribe
Comment #3
mfer CreditAttribution: mfer commentedIs there an callback in core or an example module that can be used to test this out with links?
Comment #4
merlinofchaos CreditAttribution: merlinofchaos commentedGrab the example for my ajax presentation today off of my blog at http://angrydonuts.com -- that contains simple links that do stuff with the throbber.
Comment #5
effulgentsia CreditAttribution: effulgentsia commentedI fully agree with this. I'd RTBC, but it would be nice to get confirmation from someone that it works as expected.
Comment #6
merlinofchaos CreditAttribution: merlinofchaos commentedI ran my demo code with this patch on, plus did some normal AJAX stuff (like poll) just to test. I'm confident this is working well. If effulgentsia is in agreement maybe we should RTBC this?
Comment #7
effulgentsia CreditAttribution: effulgentsia commentedComment #8
sunIs 'type' a reserved token?
I wonder whether we cannot find a way to expose all possible callback handlers on the ajax prototype... ideally, in a compact way (i.e., only defining empty default functions), and possibly, all of them being routed through a generic
Drupal.ajax.prototype.invoke = function (method, args)
"we" shouldn't be used under normal circumstances, as it usually hides away actual meaning. Something along the lines of:
"Prepare the AJAX request before it is sent."
(or similar)
Powered by Dreditor.
Comment #9
merlinofchaos CreditAttribution: merlinofchaos commentedIrrelevant to this patch. The progress bar is already in use with that token.
Would probably be best to do that through a separate patch. We're running real short on time here.
Comment #10
sunAlright, so how about this?
Comment #11
merlinofchaos CreditAttribution: merlinofchaos commentedRerolled with only sun's js doc improvement.
Comment #12
sunYes, let's do this.
#954804: All .js in /misc should be registered as a library is going to be a "required" follow-up (without hard dependency on this one, but manual testing revealed breaking JS, because progress.js is not loaded).
Comment #13
webchickOk. Since this represents a regression from CTools, it's sort of in "now or never" mode. According to sun, this function rename shouldn't actually break anything, since CTools is the only project that uses it.
Committed to HEAD.