Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The attached patch uses the deep copy version of $.extend. If your module adds JS values to the Drupal.settings.myModuleValues by using deep copy $.extend we make sure that an AJAX response that adds a new value to those settings is actually merged into the object instead of replacing it completely.
Ajax Load module suffered from the same issue: #943132: Scripts Settings need to be deep copied.
Comment | File | Size | Author |
---|---|---|---|
#14 | ctools_ajax_render_3-999164.patch | 2.18 KB | mrjeeves |
#6 | ctools_ajax_render_2.patch | 2.08 KB | mrjeeves |
#5 | ctools_ajax_render.patch | 2.09 KB | mrjeeves |
#4 | ctools_deepcopy_2.patch | 1.12 KB | mrjeeves |
ctools_deepcopy_1.patch | 411 bytes | andreiashu |
Comments
Comment #1
drewish CreditAttribution: drewish commented+1 I just ran into a bug were settings were disappearing.
Comment #2
drewish CreditAttribution: drewish commentedAlso worth pointing out that this is what D7's setting command does:
Comment #3
andreiashu CreditAttribution: andreiashu commentedHopefully we can push this into the next version of ctools?
Comment #4
mrjeeves CreditAttribution: mrjeeves commentedi've reviewed the patch above and added an update to the preprocess function on the server-side to the same effect. this issue is blocking the dependency of ctools for the 2.x branch of ajax_load. this is against the latest dev
Comment #5
mrjeeves CreditAttribution: mrjeeves commentedooook, after working on this issue more, and looking over the d7 stuff again, the merge flag is really handy, this patch includes a merge arg and also implements a $return arg for the ctools_ajax_render function because I prefer the argument order and I need it as well, If you would like the $return arg patch separate, just let me know.
Comment #6
mrjeeves CreditAttribution: mrjeeves commentedand once more changing the 'else if' to 'elseif'....
Comment #7
kevinob11 CreditAttribution: kevinob11 commented+1 this just killed me on a custom module. Any chance we can get his committed?
Comment #8
andreiashu CreditAttribution: andreiashu commentedWe can set this as rtbc. @mrjeeves patch in #6 looks robust and extends the API while keeping the existing defaults.
Comment #9
mrjeeves CreditAttribution: mrjeeves commentedThank you. I've been waiting a good minute for this to be rtbc, I'd really like to see this change made as it would allow me to work further on the "live" updates system I've imagined possible for some time.
Comment #10
kevinob11 CreditAttribution: kevinob11 commentedI ended up just overriding the js function with my own with the same name. I'm not particularly sure if this is 100% safe to do or best practices (I would love to hear about it if it isn't) but since ctools ajax ended up in core in D7 I think most of the changes to D6 version are bug fixes rather than feature requests. I just wanted to throw the idea out there because it works quite well for me and doesn't require hacking ctools or waiting for this to be committed.
Comment #11
klonos...coming from #1060340-10: Port AJAX load module to drupal 7.
Comment #12
mrjeeves CreditAttribution: mrjeeves commentedThis issue has be open for ages, the patch is small and robust, what do we have to do to get some attention on this matter???
Comment #13
rjbrown99 CreditAttribution: rjbrown99 commentedNot sure why, but #6 was causing issues for me when using jCarousel in a modal. Specifically, this line in ajax-responder.js:
It was causing my jCarousel javascript to not be executed. I tried it with the original patch in the issue, and I do not have a problem if it looks like this:
I'm short on time at the moment so I'm just reporting it. No suggested fix for now but I'm happy to provide extra information if needed.
Update: It works properly for me if we do something like the D7 version, such as:
Comment #14
mrjeeves CreditAttribution: mrjeeves commentedreroll with additions from #13
Comment #15
chiddicks CreditAttribution: chiddicks commentedI'm just in the process of testing #14. I appreciate that from a backward-compatibility perspective adding a parameter to ctools_ajax_render is the safe choice, but is there any case where doing a deep merge is going to break functionality? As far as I can see, there's very little risk aside from a slight performance hit client-side?