Problem:
Using 7.x-2.x-dev (July 11, 2015) with the AJAX auto save feature on, does not save the table order automatically.

Expected Result:
After enabling the AJAX auto save feature, dragging table rows should automatically save their order without having to click the "Save" button.

Issue:
Looking at the rendered table output of a draggable view, I see that the "Save" button has an ID of edit-save-order.
Looking at the javascript in draggableviews_table.js I see that it is expecting to find a button with an ID of edit-submit.

Fix:

Change line 22
FROM:
$table.parent().find('.form-actions input[id^="edit-submit"]').triggerHandler('mousedown');
TO:
$table.parent().find('.form-actions input[id^="edit-save-order"]').triggerHandler('mousedown');

Change line 34
FROM:
$('#' + prop).parent().find('.form-actions input[id^="edit-submit"]').hide();
TO:
$('#' + prop).parent().find('.form-actions input[id^="edit-save-order"]').hide();

The code in draggableviews_list.js also seems to have this issue.

Patch incoming...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

wOOge created an issue. See original summary.

wOOge’s picture

Issue summary: View changes
iStryker’s picture

Thoses lines were changed to support multiple forms. See #1989128: Ajax auto submit not working when multiple forms. Maybe the patch I commit as wrong/incomplete. Make sure you do not break multiple forms.

Thanks for finding this!

iStryker’s picture

Thought I wouldInclude commit in 1989128
commit from old issue

wOOge’s picture

Status: Active » Needs review
Related issues: -#1989128: Ajax auto submit not working when multiple forms
FileSize
1.99 KB

@iStryker — I only changed the ID and left all of the find logic in your original modifications.
Here is a patch — needs review and testing by the community.

wOOge’s picture

kopeboy’s picture

Priority: Normal » Major
Status: Needs review » Needs work

Just applied this to latest dev and not working.

The order is saved if I click the button, but if I don't, changing the order, waiting some seconds and refreshing the page will show the old order.
Also, the button is not hidden, but I guess it should be?!

I am using a single view with table format, with Draggableviews: Content field and Draggableviews: Weight (asc) sort.

  • The view display is a content pane.
  • Ajax is enabled.
  • Use Panel path:Yes

Maybe some specific jquery version required?

I was surprised even the stable release of a module which so many users it's not working as advertised.

UPDATE: I noticed the autosave doesn't work when using any style other than the HTML list. So maybe it's the theme that is altering the tabledrag.js? I am using Radix theme (dev).

ShaunDychko’s picture

The attached patch fixes auto-save with AJAX for both Table and HTML List styles. It adds two classes to the submit button. One is prefixed with 'js' as per Drupal coding standards for classes that are targets for JS selectors (see https://www.drupal.org/coding-standards/css/architecture#separate-concerns). The other class hides the submit button with CSS rather than using JS. Hiding with JS caused a short "flash" of the button before JS finished executing.

The jQuery selector is now more generic, using closest('form') rather than parent() to accommodate themes that styles Views differently. In my use case the tables are surrounded with a div to enable responsiveness using Bootstrap, which broke with the parent() function. I'm not really sure how the ID of the submit button is set, but a change in the ID is what started this issue, so it's better off to search for a class that the module specifically adds.

ShaunDychko’s picture

Just noticed that 'draggableviews' should be one word in class names.

RogerRogers’s picture

#8 Works for me. I'm also using bootstrap theme. Thanks @ShaunDychko

NWOM’s picture

Status: Needs review » Reviewed & tested by the community

#9 worked applied cleanly and worked great. It also fixed the problem where the save button would not disappear on bootstrap themes: #2628890: save button not hidden on ajax-updated views - some themes i.e. bootstrap

joseph.olstad’s picture

subscribing

  • ShaunDychko authored cd83806 on 7.x-2.x
    Issue #2562491 by ShaunDychko, wOOge, iStryker: AJAX Auto Save Order...
iStryker’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thanks

Status: Fixed » Closed (fixed)

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