Hello!
As the title says I discovered that when having two forms on the same page the ajax auto submit dosen't work. Looked at the file draggableviews_table.js and saw that it looked for the id #edit-actions, on my it was #edit-actions--2. It also look for a input field but I use the button element.

Comments

StoraH’s picture

Status: Active » Needs review
StatusFileSize
new741 bytes

Here is the patch :)

StoraH’s picture

StatusFileSize
new1.05 KB

Updated patch. Just saw it was the same issue with hide the submit button.

mvc’s picture

similar problem with ajax & lists, patch attached. i didn't actually test the other patch because i'm not using a table view so i didn't merge these two into one patch, but i'm posting here in case it's helpful for someone.

in my case this broke when i enabled the masquerade module, which adds its own submit button to the page.

rj’s picture

OK I just spent the last couple of hours trying to track this down and found this ticket. Here's what happens:

  • If you have more than one draggable view on a page, saving via ajax only works on the view that has a button where the ID either equals edit-actions or edit-submit; if there are multiple views then the forms with edit-actions--2 or edit-submit--2 will not work
  • DV also removes save buttons using the same logic, meaning that if there are multiple ajax-save forms on a page then only one button is removed.
  • Furthermore, it gives a success message after moving items (eg. "order of this view has been changed") even though an ajax call is not made.

It would be nice if this issue was fixed. The attached patch combines the above two patches with a minor change to StoraH's patch.

rj’s picture

Issue summary: View changes

typo.

nicolas bouteille’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

This module is awesome and this patch made my day! RTBC!! Please commit :)

istryker’s picture

Just to confirm, Patch #4 should be added? Patch #2 solves this using a different command. So scrap #2 and go with #4?

StoraH’s picture

Hmm.. I'm not sure. If we only want to fix the issue with multiple forms on one page, patch #4 should do it. But that will only support input element as submit which is not so good.

istryker’s picture

what other things should be support

StoraH’s picture

As mentioned in the issue description, the button element. We should select the submit with a class so we are not bound to that html element.

Or did you mean other than that?

istryker’s picture

What I picture is the class on the submit button not be a submit--number, rather, class_with_view_name-submit. Then you do not have to do a find the closet submit button, you can do find THIS submit button matches my name.

StoraH’s picture

I agree, something in that direction sounds good.

istryker’s picture

Status: Reviewed & tested by the community » Needs work

Marking as needs work in favor of a solution that is class_with_view_name-submit vs submit--number.

istryker’s picture

Patch to class to submit and action ids

diff --git a/draggableviews.module b/draggableviews.module
index 650a7db..b6c7f12 100644
--- a/draggableviews.module
+++ b/draggableviews.module
@@ -64,6 +64,11 @@ function draggableviews_form_alter(&$form, &$form_state, $form_id) {
     }
     $form['#action'] .= '?' . drupal_http_build_query($get);
   }
+
+  // If there is multiple forms on the page then an integer is added to the actions and submit id.
+  // We do not want this.  We want to attach the view form id.
+  //$form['actions']['submit']['#id'] = drupal_html_id('edit-submit-' . $form_id);
+  //$form['actions']['#id'] = drupal_html_id('edit-actions-' . $form_id);
 }

However, after reviewing the code, I do not think we need this. Created a new issue for this. #2415081: Unique id for edit-action and edit-submit

Attached is modified patch that fix multiple forms for list and tables. Note: At this time multiple list are still broken. See #1957656: Multiple draggableviews list on same page not working

  • iStryker committed 575e4be on 7.x-2.x
    Issue #1989128 by whoisinkus, StoraH, iStryker, rj, mvc: Ajax auto...
istryker’s picture

Status: Active » Fixed

Committed marking as fixed

Status: Fixed » Closed (fixed)

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