Problem/Motivation

If I use lists, instead of table, I can't get two draggableviews to work on the same page. Only the first list works. I'm using the dev version, with panels.

Comments

arirasekh’s picture

Yes I'm experiencing this issue. Has any progress been made on this?

millenium_11’s picture

Issue summary: View changes

I have experienced the same issue when trying to implement grouped table view.
I created a view which filters nodes by the Tracks content type and groups them by Album. So finally I got multiple tables with identical ID attribute and the draggable functionality was applied just to the first of them.

The simpliest fix which works for me is to override the ID of the tables on the page.

/**
 * Implementes hook_preprocess_views_view_table().
 */
function mymodule_preprocess_views_view_table(&$vars) {
  static $counter;
  if (!isset($counter)) {
    $counter = 1;
  }
  // Check whether this table view has draggableview field.
  if (!isset($vars['view']->field['draggableviews'])) {
    return;
  }

  // Check permissions.
  if (!user_access('access draggableviews')) {
    return;
  }

  // Add table class.
  $vars['classes_array'][] = 'draggable';

  // Add row class.
  foreach ($vars['row_classes'] as &$row_classes) {
    $row_classes[] = 'draggable';
  }

  $vars['attributes_array']['id'] = 'draggableviews-table-' . $vars['view']->name . '-' . $vars['view']->current_display.'-'.$counter;
  // Add javascript.
  drupal_add_tabledrag($vars['attributes_array']['id'], 'order', 'sibling', 'draggableviews-weight');
  $counter++;
}
cmstom’s picture

I also cannot use multiple HTML lists as draggableviews. Instead I have to change the style to table and then setup my own HTML list in Rewrite Output of the field.

istryker’s picture

I can confirm multiple list on one page does not work. One list works the other does not.

istryker’s picture

Title: Multiple draggableviews on same page not working using lists » Multiple draggableviews list on same page not working
Issue summary: View changes
StatusFileSize
new4.37 KB

Patch attached.

Patch is a little confusing as changing the indenting of the javascript file, changes every line.

draggableviews.module

-  $js_setting = array('draggableviews_row_class' => $class);
+  $js_setting['draggableviews_row_class'][] = $class;

draggableviews_list.js

-    $('.views-form .' + Drupal.settings.draggableviews_row_class + ':not(.draggableviews-processed)', context)
+    $(Drupal.settings.draggableviews_row_class).each(function(index, row_class ) {
+      $('.views-form .' + row_class + ':not(.draggableviews-processed)', context)

Patch summary: #1 Change DOM setting from a class value to an array of class values. #2 In javascript process each list form.

istryker’s picture

Status: Active » Fixed

I got this working on a normal page with 2 list. If you have another situation, like with panels, and it does not work, then reopen issue.

  • iStryker committed f7dc99f on 7.x-2.x
    Issue #1957656 by RogerRogers, iStryker: Multiple draggableviews list on...

Status: Fixed » Closed (fixed)

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