In #360545: Error with Form Block module a JS hook was provided with which it is possible to modify what happens on form submission of an ajaxified form.
As discussed there it would be great to have a UI for this.

Comments

brendoncrawford’s picture

Assigned: Unassigned » brendoncrawford
Priority: Normal » Minor

This will be done, but you will need to wait a few weeks.

Thanks,
Brendon

paganwinter’s picture

You have another 'requestee' :P

brendoncrawford’s picture

Still working on this. Hang tight.

celstonvml’s picture

I might be barking up the wrong tree, but is this regarding the "complete" hook for the JavaScript API, as described here?

http://drupal.org/node/349961

Seems like it would be as easy as adding "Drupal.Ajax.invoke" when redirect is NULL

Drupal.Ajax.response = function(submitter, formObj, data){
  var newSubmitter;
  /**
   * Failure
   */
  if (data.status === false) {
    Drupal.Ajax.updater(data.updaters);
    Drupal.Ajax.message(data.messages_error, 'error', formObj, submitter);
  }
  /**
   * Success
   */
  else {
    // Display preview
    if (data.preview !== null) {
      Drupal.Ajax.updater(data.updaters);
      Drupal.Ajax.message(decodeURIComponent(data.preview), 'preview',
        formObj, submitter);
    }
    // If no redirect, then simply show messages
    else if (data.redirect === null) {
      if (data.messages_status.length > 0) {
        Drupal.Ajax.message(data.messages_status, 'status', formObj, submitter);
      }
      if (data.messages_warning.length > 0) {
        Drupal.Ajax.message(data.messages_warning, 'warning', formObj, submitter);
      }
      if (data.messages_status.length === 0 &&
          data.messages_warning.length === 0) {
        Drupal.Ajax.message([{
          id : 0,
          value : Drupal.t('Submission Complete')
        }], 'status', formObj, submitter);
      }
      Drupal.Ajax.invoke('complete');
    }
    // Redirect
    else {
      window.location.href = data.redirect;
    }
  }
  return true;
}
brendoncrawford’s picture

Celstonbg,

Yes that is what is currently happening in the dev releases (not stable AFAIK). But the original poster is asking about cancelling a redirect even when one has been specified by a module. I am about 80% done with building out this functionality, and it should be up in another couple weeks.

brendoncrawford’s picture

Status: Active » Fixed

This has now been added to 6.x-1.x-dev as a new plugin, "disable_redirect". Please allow up to 12 hours for the new release to update. Also, please read the included README and be sure to give me your feedback if this properly suits your needs.

Thanks,
Brendon

tstoeckler’s picture

Works just as described, thank you very much for your persistence.

Status: Fixed » Closed (fixed)

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

tayzlor’s picture

Status: Closed (fixed) » Active

how do you select these options?
i don't see any option via the user interface on admin/settings/ajax , is it supposed to be there?
or do we have to add extra items to the form via hook_form_alter() ?

i've downloaded the latest dev snapshot by the way.

tstoeckler’s picture

Category: feature » support

You need to disable the "Disable redirect" module, which comes with the AJAX package. Then, if you go to admin/settings/ajax, you can not only select to use AJAX for a form, but also whether you want to disable the redirect.

tayzlor’s picture

Category: bug » support

aah, doh, what an idiot!

slight bug with this, drupal_set_message() messages dont get displayed on the screen after submit if the disable_redirect option is enabled on forms. when you then navigate to the next page the drupal message gets displayed.

tayzlor’s picture

Category: support » bug
tayzlor’s picture

Category: support » bug

not sure if this is the right place, but, to add more to this issue, it would also be nice if after form submission it displayed the node 'view' page WITHOUT a redirect in place. would this be something that could be incorporated into this plugin?

is it possible to have another plugin run straight after this one? so i could write my own which fires right after the js function stopping the redirect and removing the content which goes and fetches the node and displays it in place like you are viewing the node again?

brendoncrawford’s picture

tayzlor,

Could you open 2 new issues for the items you mentioned, then close out this bug?

1) Messages not being displayed if redirect is disabled..

2) Populating a block with node_view if redirect is disabled. (I think this is an excellent idea, by the way)

tayzlor’s picture

Status: Active » Closed (fixed)

done,
issues are in -

http://drupal.org/node/391146 and

http://drupal.org/node/391136 respectively.

closing this issue.

doublejosh’s picture

Yup the message works me as well.

Confirming Ajax (w/ disable redirect) + Form Block works like a charm.