This is closely related to #360246: Error on submit content type but I suppose it should be considered a different issue:
Using the Form Block module, I use the "Add content" form as a block on the right sidebar. I want to create something like a "Shoutbox", so I don't want the page that I am viewing to show anything else than before, when submitting content. Currently, although having ajaxified the form in question, the page reloads to show the added node.

I marked this as bug report, because it says on the project page, that you do not need to reload your page with an ajaxified form. Could be feature request as well, due to the specific configuration, feel free to change.

Comments

brendoncrawford’s picture

Tsoeckler,

After the form is submitted, what are you wanting to happen next?

tstoeckler’s picture

I want for the node to be submitted. Above the Form Block I have a View showing a list of the submitted nodes. Now I'm guessing without a page refresh Views has no chance to grab the new data, but I'm also guessing that's not part of AJAX module's business. I just want whatever page I'm looking at, to still be there and the form to be submitted.

brendoncrawford’s picture

Assigned: Unassigned » brendoncrawford
Category: bug » feature
Priority: Normal » Minor
Status: Active » Fixed

I have added a new JavaScript hook in 6.x-1.x-dev, which may take up to 12 hours to update. This hook will allow you to do what you want. You can make a plugin to determine what happens after the form is submitted:

Drupal.Ajax.plugins.FOO = function(hook, args) {
  if (hook === 'complete') {
    if (args.form_id === 'SOME_FORM_ID') {
      alert("Form submission is complete");
      // If this returns false, no redirection will occur
      return false;
    }
    else {
      // redirection will occur
      return true;
    }
  }
  return true;
}

Let me know if you need anything else.

Thanks,
Brendon

tstoeckler’s picture

Once again, thanks very much.
Seems I might actually be about to write my own first code...

brendoncrawford’s picture

Tstoeckler,

Eventually I might build the ability to control form submission-response actions with the Ajax UI module. I suppose it depends on how many people ask for it.

take care,
brendon

ManyNancy’s picture

Hi, thanks for the new js hook. But I'm not sure where to put this? In my own module? My usecase is similar to tstoeckler's, I likewise want to use formblock to submit content like this. A UI option would be great.

Thanks.

brendoncrawford’s picture

I will build an admin UI for this feature, but it may be a few weeks.

Thanks,
brendon

brendoncrawford’s picture

Minqensan,

Can you move the UI request into a new feature request issue?

Thanks,
Brendon

tstoeckler’s picture

Status: Fixed » Closed (fixed)

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