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...
Comment | File | Size | Author |
---|---|---|---|
#9 | draggableviews-fix-for-ajax-autosave-2562491-9.patch | 2.52 KB | ShaunDychko |
Comments
Comment #2
wOOge CreditAttribution: wOOge commentedComment #3
iStryker CreditAttribution: iStryker commentedThoses 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!
Comment #4
iStryker CreditAttribution: iStryker commentedThought I wouldInclude commit in 1989128
Comment #5
wOOge CreditAttribution: wOOge commented@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.
Comment #6
wOOge CreditAttribution: wOOge commentedComment #7
kopeboy CreditAttribution: kopeboy commentedJust 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.
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).
Comment #8
ShaunDychko CreditAttribution: ShaunDychko for Bellin commentedThe 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 thanparent()
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.Comment #9
ShaunDychko CreditAttribution: ShaunDychko for Bellin commentedJust noticed that 'draggableviews' should be one word in class names.
Comment #10
RogerRogers CreditAttribution: RogerRogers commented#8 Works for me. I'm also using bootstrap theme. Thanks @ShaunDychko
Comment #11
NWOM CreditAttribution: NWOM commented#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
Comment #12
joseph.olstadsubscribing
Comment #14
iStryker CreditAttribution: iStryker commentedCommitted. Thanks