If you have a modal frame with a form
ctools_modal_form_wrapper()

if you try to use
'#attributes' => array('class' => array('ctools-auto-submit')),
within.

It will dont handle the ajax.
It whill open the ajax url and show the json in browser.

Comments

merlinofchaos’s picture

Are you sure that ctools_include('auto-submit') happened on the page where this happens?

It is possible that the auto-submit and the modal frame aren't happy together, because modal frame is taking over the click or something and they don't work well. It might take some effort to debug something like that.

greenrover33’s picture

Yes i didt include all nessesary

populist’s picture

I ran into this same problem and did some additional research. The behavior I see is that if I add the appropriate code to make the form autosubmit, it will autosubmit but will just return the JSOn in the browser. This is the same behavior if I use jQuery to either .click() or .trigger('mousedown') on the submit button.

However, if I manually click on the button in question it will handle the submit function correctly! My guess is there is some chaos magic present on the modal form submission likely injected by Drupal.behaviors.ZZCToolsModal but I don't know the right way to make it all work nicely together.

merlinofchaos’s picture

Okay, a little research shows us that this is a bug in the version of jquery with Drupal 7:

http://forum.jquery.com/topic/click-on-submit-button-doesn-t-trigger-for...

I'm trying to find a strategy to work around this bug.

One workaround would be to use jquery_update but I don't know what version of jquery the bug was actually fixed in at the moment. And there are issues with Drupal 7 and jquery 1.7.

merlinofchaos’s picture

Title: auto-sumit in combination with modal frame » auto-submit in combination with modal frame
Status: Active » Needs review
StatusFileSize
new743 bytes

Okay, so this patch appears to work around the bug for the modal, at least. I tested it in Chrome, Firefox and IE9 and it appears to be sane. My big question is whether or not this will be ocmpatible with later versions of jQuery, which I don't have easily handy.

Status: Needs review » Needs work

The last submitted patch, 1198808-work-around-jquery-bug-with-auto-submit.patch, failed testing.

populist’s picture

Here is a quick re-roll against Chaos Tools 1.0.

merlinofchaos’s picture

Status: Needs work » Fixed

The reroll in #7 didn't actually apply so I committed my original patch and pushed.

Automatically closed -- issue fixed for 2 weeks with no activity.