Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
javascript
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
29 Nov 2009 at 05:44 UTC
Updated:
22 Jan 2010 at 07:30 UTC
Jump to comment: Most recent file
I don't think there's a reason for why we should limit the settings that can be passed via the #ajax element property.
Additionally, the 'effect' and 'speed' properties were using the same element property as source (bug).
Furthermore, the current code doesn't allow a custom 'path' to use a 'callback'. There's no reason why a contributed module shouldn't be able to fork system/ajax, if required, but still use callbacks.
Lastly, due to direct invocations of drupal_add_*() functions, the attached JavaScripts and settings cannot be cached.
Attached patch fixes all of that.
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | drupal.ajax-process-form.17.patch | 4.63 KB | sun |
| #16 | drupal.ajax-process-form.16.patch | 9.5 KB | sun |
| #14 | drupal.ajax-process-form.14.patch | 8.84 KB | sun |
| #6 | drupal.ajax-process-form.6.patch | 4.48 KB | sun |
| #4 | drupal.ajax-process-form.4.patch | 9.76 KB | sun |
Comments
Comment #2
sunoh my... sorry, it's late here. :P
Comment #4
sunok, I should really learn to copy + paste. :P
Also speeds up AJAX commands test.
Comment #6
sunok, seems like the test didn't like that optimization for whatever reason. Reverted those changes.
Comment #8
sunInteresting. This seems to reveal a bug elsewhere.
This patch changes
into
But Drupal.settings.ajax contains only the first element that is processed on a page.
Comment #9
sunmeh, silly me. This actually works like it should and is a major improvement on its own: The second AJAX settings were for a "Remove" button of a multiple value field widget in the form, which does not have a value yet, hence, the the settings were needlessly added before.
Comment #10
sunClusterfuck. Better title.
When returning an AJAX command array, drupal_render() is not invoked, so #attached is not processed when submitting a form via AJAX. See http://api.drupal.org/api/function/ajax_deliver/7
At least, that's my current assumption. Not verified.
Comment #11
robloachHmm, interesting. Making a note to have a look as it seems pretty critical.
Comment #12
katbailey commentedRelated: #647228: Links are needlessly unable to fully participate in D7 AJAX framework features
Comment #13
effulgentsia commentedAlso related (to the path/callback fix): #649628: Make it easier to write AJAX-enabled forms that fully work with JavaScript disabled too.
Comment #14
sunI'm a bit stuck in here. Not sure whether it's only the AJAX commands test that needs to be updated. If this patch works, then we only need to test manually whether AJAX still works with this patch ;)
Comment #16
sunThis will make the remaining pass.
I mentioned manual testing above, because I'm not sure whether there is a full test of AJAX multiple value field operations: Add an item, add another item, remove an item, all on the same field. Afterwards, ideally try to add an item in a second field.
The question is whether - after adding an item - the attaching behaviors environment will contain the AJAX settings for the remove button. And after removing, whether it will still contain the settings for the add button 8)
Not even sure whether this can be tested in an automated way, because this requires a JavaScript environment.
Comment #17
sunAnd of course, it doesn't work. Let's leave that to a separate issue, because I fear it will require quite some API changes.
Instead, I've stuffed a @todo in there that explains the situation.
Anyone up for RTBC'ing this patch?
Comment #18
sunCreated #656782: ajax_process_form() results in settings being returned for elements that aren't re-rendered as part of the AJAX request do deal with that #attached/caching problem.
Comment #19
effulgentsia commentedMakes sense and nice clean up. I want to investigate the @todo that's in there, but not today, and in any case, whatever the problem is, it's in HEAD, and this patch doesn't change it, so the rest of the nice cleanup that's here shouldn't be held up.
Comment #20
robloachI want to RTBC it, but would like to talk with tha_sun on IRC first.
Comment #21
robloachWhoops, effulgentsia beat me to it! I'm all thumbs up if he backs it! :-)
Comment #23
effulgentsia commentedas per #21
Comment #24
damien tournoud commented-1 for @todo in our code. It's not like we could plan to do something later at this point. We need that to work, fully and completely.
Comment #25
sun@Damien: That's a separate issue, see you in #656782: ajax_process_form() results in settings being returned for elements that aren't re-rendered as part of the AJAX request
Comment #26
webchickSorry, but I agree with Damien. The time for "Oh, we'll fix that in a follow-up patch" is behind us now.
Comment #27
sunerr, guys, these are completely separate issues. Please define scope-creep.
This patch fixes one bug. The other issue will need to fix the other bug.
Comment #28
sunReally, #656782: ajax_process_form() results in settings being returned for elements that aren't re-rendered as part of the AJAX request contains a very clear and concise description of the second bug. Did you actually read it?
It would be insane to intermix both issues. While this one is a regular and quite simple bug fix, the other issue should probably bumped to critical, since it questions our entire element processing, caching, and rendering, and may require larger changes to the AJAX framework and/or form processing and/or element rendering.
Comment #29
webchickI did read it. It says that this patch introduces a critical bug, by breaking AJAX with cached elements, which needs to be cleaned up afterwards. Or are you saying that that bug exists regardless of this patch?
Comment #30
sunsorry, if that didn't come through - yes, this bug exists in HEAD already. It was revealed by this patch. That's why this patch does not convert all drupal_add_js() lines into ['#attached']['js'] properties, because the settings cannot be converted currently. Figuring out why that is and how to solve it, is the focus of the other issue.
I will post a patch containing that particular change (== outlined in #8 above) to the other issue. And this one-liner will break, because something goes wrong in our form or element processing/caching/rendering.
Comment #31
webchickOops. This fell off my radar.
Ok, cool. I assume our AJAX tests would scream if anything were too odd with this patch, so committed to HEAD.