Still on Drupal 7? Security support for Drupal 7 ended on 5 January 2025. Please visit our Drupal 7 End of Life resources page to review all of your options.Hi,
I just want to thank Scott and the other maintainers again for this amazing module.
I've encountered a weird javascript bug that occurs while trying to use Facebook style Status module & Facebook style Links (http://drupal.org/project/facebook_link) along with Activity 2.x (Feb 17th dev) comments. Here are the steps to produce the problem.
Setup an Activity 2.x view with Activity comments in a panel to display FBS statuses and nodes.
Setup an FBSS plus FBSL form within the same panel.
Ensure FBSS refreshes the page upon submission of status instead of refreshing a view via AHAH.
Try inputting text into an Activity comment form and press the enter key.
Most often the page will reload without the comment submitted and the page's javascript will be broken. Some of the time a white page (with the url activity/comments/insert) loads with the following displayed:
{ "status": true, "data": "\x3cform action=\"/activity/comments/insert\" accept-charset=\"UTF-8\" method=\"post\" id=\"activity-comments-form\" class=\"activity_comment-comment-form\"\x3e\n\x3cdiv\x3e\x3cspan class=\"activity-comment-show-all\"\x3e\x3ca href=\"#\"\x3eShow all 3 comments\x3c/a\x3e\x3c/span\x3e\x3cdiv class=\"item-list\"\x3e\x3cul id=\"activity_comments-499\" class=\"activity-comment-list\"\x3e\x3cli class=\"activity-comment-wrapper first\"\x3e\x3cdiv class=\'container-inline\'\x3e\n \x3cspan class=\'activity-user\'\x3e\x3ca href=\"/user/londonfuse\" title=\"View user profile.\"\x3eLondonFuse\x3c/a\x3e\x3c/span\x3e\n \x3cdiv class=\'activity-comment\'\x3ehey now\x3c/div\x3e\n\x3c/div\x3e\n\x3cdiv class=\'activity-comments-meta\'\x3e\n \x3cdiv class=\'activity-comments-timestamp\'\x3e\n March 4, 2010 - 2:22pm \x3c/div\x3e\n \x3cdiv class=\'activity-comments-delete\'\x3e\n \x3ca href=\"/activity/comments/delete/2?destination=activity%2Fcomments%2Finsert\"\x3eDelete\x3c/a\x3e \x3c/div\x3e\n \x3c/div\x3e\n\x3c/li\x3e\n\x3cli class=\"activity-comment-wrapper\"\x3e\x3cdiv class=\'container-inline\'\x3e\n \x3cspan class=\'activity-user\'\x3e\x3ca href=\"/user/londonfuse\" title=\"View user profile.\"\x3eLondonFuse\x3c/a\x3e\x3c/span\x3e\n \x3cdiv class=\'activity-comment\'\x3eWhat\x26#039;s up\x3c/div\x3e\n\x3c/div\x3e\n\x3cdiv class=\'activity-comments-meta\'\x3e\n \x3cdiv class=\'activity-comments-timestamp\'\x3e\n March 4, 2010 - 2:22pm \x3c/div\x3e\n \x3cdiv class=\'activity-comments-delete\'\x3e\n \x3ca href=\"/activity/comments/delete/3?destination=activity%2Fcomments%2Finsert\"\x3eDelete\x3c/a\x3e \x3c/div\x3e\n \x3c/div\x3e\n\x3c/li\x3e\n\x3cli class=\"activity-comment-wrapper activity-comment-hidden last\"\x3e\x3cdiv class=\'container-inline\'\x3e\n \x3cspan class=\'activity-user\'\x3e\x3ca href=\"/user/londonfuse\" title=\"View user profile.\"\x3eLondonFuse\x3c/a\x3e\x3c/span\x3e\n \x3cdiv class=\'activity-comment\'\x3edon\x26#039;t like this.\x3c/div\x3e\n\x3c/div\x3e\n\x3cdiv class=\'activity-comments-meta\'\x3e\n \x3cdiv class=\'activity-comments-timestamp\'\x3e\n March 4, 2010 - 2:22pm \x3c/div\x3e\n \x3cdiv class=\'activity-comments-delete\'\x3e\n \x3ca href=\"/activity/comments/delete/4?destination=activity%2Fcomments%2Finsert\"\x3eDelete\x3c/a\x3e \x3c/div\x3e\n \x3c/div\x3e\n\x3c/li\x3e\n\x3c/ul\x3e\x3c/div\x3e\x3cdiv class=\"container-inline\"\x3e\x3cdiv class=\"form-item\" id=\"edit-activity-comment-wrapper\"\x3e\n \x3cinput type=\"text\" maxlength=\"250\" name=\"activity_comment\" id=\"edit-activity-comment\" size=\"25\" value=\"Write a comment\" class=\"form-text activity-comment-text\" /\x3e\n\x3c/div\x3e\n\x3cinput type=\"submit\" name=\"op\" id=\"activity-comment-save-comment-499\" value=\"Add\" class=\"form-submit\" /\x3e\n\x3c/div\x3e\x3cinput type=\"hidden\" name=\"form_build_id\" id=\"form-a49ff87204219acd49ffe4e0f61c3f13\" value=\"form-a49ff87204219acd49ffe4e0f61c3f13\" /\x3e\n\x3cinput type=\"hidden\" name=\"form_token\" id=\"edit-activity-comments-form-form-token\" value=\"2d4394493b41bd0ef63cea96aa3fc260\" /\x3e\n\x3cinput type=\"hidden\" name=\"form_id\" id=\"edit-activity-comments-form\" value=\"activity_comments_form\" /\x3e\n\n\x3c/div\x3e\x3c/form\x3e\n\x3cdiv\x3e\x3ca href=\"/activity/comments/insert?formfilter_id=activity_comments_form\" class=\"active\"\x3eFilter this form\x3c/a\x3e\x3c/div\x3e" }
Any ideas about the underlying problem would be much appreciated. I've attached the view I'm using for what it's worth.
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | fbss_without_ahah.patch | 1.53 KB | TS79 |
| #23 | fbss_ahah_dev.patch | 3.42 KB | TS79 |
| Activity_view.txt | 16.06 KB | pribeh |
Comments
Comment #1
Scott Reynolds commentedits actually a core bug: #671184: AJAX form can submit inappropriately to system/ajax after failed validation
the form action gets all mixed up. The issue title doesn't do it complete justice.
Comment #2
okday commentedsubscribing
Comment #3
Scott Reynolds commentedLooks like the core issue might not be 'backportable'. Might have to come up with a way to handle this in the module by passing the $form_state['old_action'] via the AHAH menu callback and then form_altering that bad boy into the form when it comes back.
That might not fix it though since its another module thats mixing up the form actions.
Comment #4
pribeh commentedGreat, thanks for the info Scott. Is it FBSL that's mixing up the form actions then?
Comment #5
summit commentedSubscribing, interested in the same integration..greetings, Martijn
Comment #6
Scott Reynolds commentedThats not it at all. Its a core bug thats ugly and complicated. To much AHAH makes drupal confused. Its a complicated problem that I don't have a clear pattern on how to fix.
Comment #7
summit commentedHi Scott, couldn't somebody else from the coreteam may be help you?
Just to help you in the think process...
greetings,
Martijn
Comment #8
icecreamyou commentedSubscribing. I'm the maintainer of FBSS.
This is indeed a very complicated issue. I've struggled with related issues before, unaware that this was rooted in a core bug.
I'm also experiencing this to some extent with my Facebook-style Statuses Comments module. This issue is probably also related to #710684: "Form in form" problem causes status updates to fail.
Comment #9
pribeh commentedI have yet to talk to publicmind but it appears as if he came up with a way around the bug as the problem does not arise anymore with Facebook_Link version 1.1.
Obviously though this doesn't solve the core bug which looks like it's fixed in D7 now. And there are other ways in which this bug is affecting FBSS so I'm not entirely sure if we should mark this issue as fixed. It would also be nice to see if someone else could verify if the bug is gone for them - Martijn? :)
Comment #10
icecreamyou commentedWhatever publicmind fixed, it was probably not this issue. I don't see any changes in FBSL 1.1 that would affect this.
Comment #11
pribeh commentedFor some reason though I can hit enter on Activity comments and the page reloads with the comment properly in place. I just have confirmation from several other users that they are unable to reproduce the error on my test site after having updated FBSL to version 1.1. I have made a number of other changes on this test site but am unaware as to how this could suddenly be working for me. I will try again on a fresh copy of Drupal 6 and report back.
Comment #12
Scott Reynolds commentedIf the page reloads instead of doing AJAX stuff then the AHAH properties were just removed. And if that is the case, thats not really a fix.
Comment #13
pribeh commentedHitting the add button will reload the comment in place using ajax. It only refreshes the page when hitting the enter key to submit the status just to be clear. I'm currently still investigating my setup. Going to downgrade and upgrade again.
Comment #14
publicmind commentedHi,
sorry to hit in late, as ICY mentioned I did nothing specific to fix the issue in FBSL 1.1.
But I would like to mention of this issue: #757770: Apostrophes don't work in browsers, I don't know if its related to it in any way but I was using apostrophe instead of quote somewhere to theme the image.
regards,
Comment #15
pribeh commentedHaha, well I guess it is a fluke. I've downgraded and upgraded with the same degree of success. The error does pop up now and then though so it's not a perfect fluke :)
Comment #16
pribeh commentedAaaargh. Problem is permanently back for me. Would anyone (Scott) like some support getting this resolved in D6? I'd love to get this resolved. If so, contact me.
Comment #17
icecreamyou commentedI would be rather shocked if you were able to solve this problem without fixing #710684: "Form in form" problem causes status updates to fail as well. Fixing that issue requires some fundamental changes to the way FBSS currently renders Views.
Comment #18
pribeh commentedOh nooo. Thanks for letting me know IceCreamYou. Maybe I should reconsider how I build pages with the status form, views and activity comments.
Comment #19
icecreamyou commentedFundamental changes don't necessarily mean that it will be really difficult or take a long time. Basically all that's required here is moving views_embed_view() out of facebook_status_box() and triggering a custom event in the AHAH success handler (which is already overridden in dev), then adding a listener for that event attached to the view that re-loads the view using AJAX.
Sounds complicated, but it's probably only around 4-12 hours' work. I just have to find those 4-12 hours and the motivation to do it.
Comment #20
gausarts commentedSubscribing. Thanks
Comment #21
summit commentedHi IceCreamYou,
For what's it worth I really appreciate your efforts!!!
Greetings, Martijn
Comment #22
TS79 commentedSubscribing. Many thanks
Comment #23
TS79 commentedI tried to fix the issue as described by IceCreamYou on base of facebook_status-6.x-2.x-dev.
Unfortunately I only got it for the settings "no page refresh via ahah" (fbss_without_ahah.patch).
The second (independent) patch for the ahah-part (fbss_ahah_dev.patch) works fine for insertion of new status messages, meaning the comment view get refrehes via ajax. But a second problem appeared: if you wan't to insert any new comment after updating the status message, a similar failure to the inital one of this issue shows up. When you want to insert a new comment after(!) status message update, a new pageload is required to avod the failure.
Since there is always a new pageload after status insertion without ahah enabled, the problem does not appeare with this setting.
Remark: ahah-patch only works for view "facebook_status" atm (hard coded in .js file), since I stopped working on it after I recognized the new problem.
Comment #24
icecreamyou commentedmaster-of-magic, thanks for your efforts. But first of all, you diff'd your patches backwards, from the new to the old instead of old to new. :-P
Second of all, as noted in the issue where the problem you attempted to tackle is actually being discussed, I'm already working on this. You have the right idea, but you missed some key parts. Also the approach I'm taking more generically (and cleanly) allows anything on the page to be refreshed when a status is submitted, not just a single view. I'm fairly close to finished with my implementation.
This issue exists separately from the "form-in-form" bug because there are probably deeper issues in Drupal core FAPI-with-AHAH. So even when the "form-in-form" bug is solved, FBSSC and Activity Comments still might not work completely as expected. I'm not familiar with the exact problems, but Scott apparently is, and they are discussed here.
I encourage you to continue helping with patches. Once I fix (what I hope is just) one last problem I will commit or post a patch with my progress on the "form-in-form" issue and we can build from there.
Comment #25
ajayg commentedComment #26
icecreamyou commentedAlthough I forgot to update this issue, the form-in-form problem is fixed. I have had no problem with Facebook-style Statuses Comments due to the very generic approach I took with fixing the form-in-form problem, so if there is still an issue with Activity Comments, it can very likely be fixed without a core patch (and also probably isn't related to FBSS).
In addition, FBSL is deprecated in favor of FBSMP.
Comment #27
Scott Reynolds commentedThis bug is hard, but its fixable with a little form magic. It shouldn't take that much time its just finding time to devote to this.
Comment #28
oxford-dev commentedI'm finding a different problem with the latest alpha version.
On my production site, im using an old dev version which works fine, I can add comments via ajax, i can add status updates and the fbss updates the view via ajax, still fine. If i add a comment after adding a status update then the page needs to refresh which isnt ideal but at least it works.
However with the latest alpha, i can add a comment, i can add a status update but if i try to add a comment after an update then nothing at all happens.
I can see in FF console that the 'POST' isnt being sent from the comment form.
Comment #29
pribeh commented@oxford-dev, I'll see if I can duplicate this today.
Comment #30
oxford-dev commentedJust had another look at this and it seems clear that its because after a fbss update the activity view is reloaded via Ajax, this means the new dom elements are not having the comment jquery attached to them. If you were using the latest version of jQuery then the event bindings could be replaced with 'live' but i'm sure this is not likely to be common.
So I think it would be good to go back to the earlier version with the standard form submit which isn't ideal but at least it worked.
Comment #31
icecreamyou commentedIf Activity's JS is compliant with Drupal standards, it will automatically be attached to the new DOM after an AHAH update. And it looks to me like this is the case, although there is a related bug which may or may not solve this problem.
As an example, take the first part of activity_comments.js:
When a form is submitted via AHAH, this code is run again. Because the binding selectors are applied with $(), they work on the whole document; so every time a form is submitted via AHAH the behaviors get re-attached to everything that matches the selector on the entire page. This problem is mitigated by toggling "processed" classes on the processed elements.
Instead, it should be better to use $(context).find(), which will only process the new DOM (in the case of a full page load,
contextwill bedocument).Comment #32
oxford-dev commentedI've also since realised that this isn't exactly the problem too.
The jQuery is being attached and is being triggered as you can follow the execution in firebug.
After pressing enter or clicking 'add', the js runs through activity_comments.js and at line 37
$(this).parents('form').find('input[type=submit]').mousedown();
this is where the form should be submitted but it just skips over it without doing anything.
Comment #33
_shyD6 reached its EOL back in February 2016, and there is no active release for D6 for this module anymore.
Development or support is not planned for D6. All D6-related issues are marked as outdated in a bunch.
If the issue remains relevant for D10+ versions, merge requests with proposed solutions for a new module version (D10+) are welcome in a new follow-up issue.
Thanks!