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.
To reproduce:
I added the following to my submit element (in an otherwise non-ajaxed form):
'#attributes' => array( 'class' => array ( 'use-ajax-submit' ) ),
And then, upon form submission, I get a console js error that 'TRUE is not defined'.
element_settings.set_click = TRUE;
is the offending line (58)
I'm new to the patch game, and I'm attaching one, so please feel free to direct me on how to do it the right way (including any protocols I might have inadvertently ignored).
Comment | File | Size | Author |
---|---|---|---|
#32 | drupal.ajax-selector-once.32.patch | 11.8 KB | sun |
#31 | drupal.ajax-selector-once.31.patch | 3.58 KB | sun |
#30 | drupal.ajax-selector-once.30.patch | 2.88 KB | sun |
#26 | drupal.ajax-use-submit.26.patch | 2.16 KB | sun |
#25 | drupal.ajax-use-submit.25.patch | 1.6 KB | sun |
Comments
Comment #1
Meriial CreditAttribution: Meriial commentedComment #2
rfaySubscribing. Setting to needs review so it gets tested. However, we have no test coverage for this, of course :-)
Comment #3
merlinofchaos CreditAttribution: merlinofchaos commentedAs part of the CTools upgrade, we discovered that this AJAX path has never been used. A bunch of minor changes are required for CTools to utilize its typical javascript paths, including some prevention from multiple submits while waiting and using a try { } catch { } block and making sure the proper values are set.
Comment #4
rfayThe use-ajax-submit is comfirmed completely broken as described in the original issue here.
I can't get it to work rationally with either #1 or #3 though. With #3, my form submits and the animation continues forever, leaving the page in a broken state.
Attached is a super-simple test module to demonstrate use-ajax-submit.
Comment #5
int CreditAttribution: int commentedcritical? no..
Comment #6
merlinofchaos CreditAttribution: merlinofchaos commentedReally? A crash bug isn't critical?
Comment #7
merlinofchaos CreditAttribution: merlinofchaos commentedIt's a crash bug. crash bugs are critical, IMO.
Comment #8
merlinofchaos CreditAttribution: merlinofchaos commentedAlso and maybe this is egotistical, CTools needs it.
Comment #9
rfayMarked #918812: Ajax.inc attach behavior broken for submit buttons, typos and missing properties as a duplicate.
Comment #10
adrian CreditAttribution: adrian commentedsince my other issue got closed even though it had a valid patch in it
#918812: Ajax.inc attach behavior broken for submit buttons, typos and missing properties
here's the patch from that issue.
there are other typos and full missing lines of code in that block.
Comment #11
rfayBoth of the changes in #10 were already done in the patch we're working with in #3. #3 is the "live one"
Comment #12
rfaySetting back to "needs work". And really, I (or someone before me) just needs to get this boiled down into a tiny test/demonstration environment.
Comment #13
rfay@alex_b: Saw your ping - sorry couldn't respond.
The reason we need some demonstration code:
1. The patch is #3, not #10. Larger than 2 lines.
2. We *must have* either demonstration code or valid tests (probably both for javascript-related stuff) for every issue. The reason this stupidity got in here is that the code had never been executed. Let's not have code in core that has never been executed any more. Now that #789186: Improve drupalPostAJAX() to be used more easily, leading to better AJAX test coverage has gone in, we *may* be able to write a valid test, which would be great. But IMO a piece of UI code which has no live demonstration in existence is no code at all.
-Randy
Comment #14
adrian CreditAttribution: adrian commentedI tested this using the drupal 7 port of the boxes module hosted here -
github.com/vertice/boxes
along the ctools from here :
github.com/developmentseed/ctools
the patch from #3 definitely resolves the issue.
Comment #15
adrian CreditAttribution: adrian commentedhere is the working version of your demo module.
the reason no working code for this ever existed is because it has been a broken and dead/unused code path for a very long time indeed.
Comment #16
merlinofchaos CreditAttribution: merlinofchaos commentedThe reason it was broken is primarily that it is a code path that came from CTools when the AJAX framework was installed.
There is clearly a bug when there is an AJAX error (which is why the submit button died). I suspect my unsetting .ajaxing in complete is wrong. I have not had a chance to revisit this since the sprint (sorry, it's been that kind of week) but this is very important to me so I assure you that I will. Right now the CTools D7 work is dependent upon this patch (and the lazy-loading patch).
It's possible we could split this patch up into two, because part of the patch (the double-click prevention) is separate from restoring the use-ajax-submit pathway and making it actually work. I'm not sure I want to do that since two patches are harder to get in that one, and the double-click prevention is, IMO, a critical bugfix in and of itself. =)
Comment #17
adrian CreditAttribution: adrian commentedI think the first part (my patch) could be considered it's own thing.
it's just fixing 2 typos, one of which is a compile time error(!) , and adding a missing line present in all the other blocks in that function.
Comment #18
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Happy birthday, Earl. ;-)
Comment #19
lalit774 CreditAttribution: lalit774 commentedhi
i got this error . when ever click on submit button.
An error occurred while attempting to process /detracs/use_ajax_submit: ajax.form.ajaxSubmit is not a function
Thanks
Comment #20
merlinofchaos CreditAttribution: merlinofchaos commentedThat would indicate that the code using it did not do:
Comment #21
sunIs type a reserved token?
This looks a bit odd to me. Elsewhere, the AJAX framework is using _triggering_element* POST data to identify and specially handle AJAX submissions. Since this key/value pair is not used anywhere, this change at least deserves a code comment.
Trailing white-space.
Powered by Dreditor.
Comment #22
merlinofchaos CreditAttribution: merlinofchaos commentedA what? I know that in most cases I've advocated using url mangling (i.e, nojs/ajax) to handle this, but there are times when doing that is not convenient so having a $_POST identifier is what I was going for. I'm not sure what _triggering_element means in this case.
Don't look at me. The 'progress' object is used by the ajax object to determine what progress bar to show. I was simply making the throbber the default because on the submit buttons, using the more complex "Loading" progressbar pushes sibling buttons all over the place in a way that is unattractive. The throbber is actually only slightly better but I figure I can clean it up with CSS in my forms. That's always been a bit of a visual problem that I haven't had good solutions for.
Comment #23
EclipseGc CreditAttribution: EclipseGc commented#21: drupal.ajax-use-submit.21.patch queued for re-testing.
Comment #25
sunAttached patch is what remains. Other parts were cleaned up through other patches already.
Comment #26
sun1) Processing code for Drupal.settings.ajax also uses some uncommon way to process each item. Fixed in attached patch.
2) None of the jQuery selectors in Drupal.behaviors.AJAX takes the context into account. Fixed in attached patch.
Comment #27
sunSomehow, neither the old nor the slightly improved code makes really sense to me.
The actual elements to ajaxify are denoted in
settings.ajax[base].selector
But we are turning base into an HTML ID (i.e., #base) and testing whether we already processed that element.
So if base is not identical to .selector, that check will fail, and we're processing the elements more than once.
Additionally, this current code effectively selects the elements twice -- i.e., once for #base, and once again for .selector.
Was there any undocumented reason for doing it that way, or is this just a bug?
Powered by Dreditor.
Comment #28
sun@merlinofchaos: Any feedback on #27? The current code looks a bit broken to me. It technically means that AJAX events are potentially bound multiple times on elements in edge-cases (primary prerequisite: existing ajaxified content is not removed from the page, and a subsequent AJAX request uses a selector that happens to select previously ajaxified elements).
Comment #29
sunFeedback, anyone?
Additionally, #951262: Move #ajax default settings from PHP into JS needs a confirmation, too. The patch helps us to attach AJAX events on the actual #ajax .selector.
Comment #30
sunIncorporated the relevant line from #951262: Move #ajax default settings from PHP into JS
However, the @todo I added in this patch leaves me in the dark. Evaluating the current code in HEAD,
Any clues, anyone?
Comment #31
sunRe-rolled for #951262: Move #ajax default settings from PHP into JS
@merlinofchaos: Would love to discuss the @todo in this patch with you.
Comment #32
sunAlright, discussed with @merlinofchaos in IRC, and the proper fix is to make Drupal.ajax() support multiple elements (and therefore only binding once on all matched elements), while still ensuring backwards-compatibility.
Attached patch changes the
element
argument to$elements
(a jQuery object), and ensures that potentially existing code does not break when passing a DOM node.The patch is a bit larger, since during reviewing where
ajax.element
is currently used, I got confused since a couple of handlers are still usingthis
instead ofajax
, so I changed that to be consistent.Comment #33
rfayHas to go into 8.x first.
Comment #34
astutonetHi.
I've been experiencing serious problems with ajax in D7.
I can not edit or create views. I also have problems with panels.
When I try to edit, create, view, or simply close a window of the views module, I get the following message:
In a way, my site is down. I wonder if my problems are related to the issue discussed here and if anyone can help me, pointing to a solution, because I'm not finding the problem nor the solution. If so, I will open a new issue.
Thank you.
Comment #35
rfay@astutonet, you need to open a new support issue, or post to a good support location like http://drupal.stackexchange.com.
The first thing to do is to see if you can recreate the problem on a very simple Drupal install (with views). Then you can begin debugging. It's most likely another module. You should also make sure you have the latest of everything. Some debugging hints are at http://randyfay.com/debugging.
Comment #36
astutonet@rfay, I will try to reproduce the problem through a new installation, but I think it will be difficult because the site in question is an updated version of a site originally created with the D6, therefore, was born with its own content.
Even though I can not reproduce the error, I will create a new issue and report here.
Tks.
Edit:The new issue about #34 is here: http://drupal.org/node/1380370
Comment #37
kscheirer#32: drupal.ajax-selector-once.32.patch queued for re-testing.
Comment #39
mgifford