Drag and Drop buggy with jQuery 1.3 in Drupal 6.x
kenorb - April 29, 2009 - 15:03
| Project: | jQuery Update |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | needs work |
Jump to:
Description
After Upgrade 6.x-1.x-dev to 6.x-2.x drag and drop in Views doesn't work properly (jquery.js file)
Step to reproduce:
1. Edit some View with some Filters.
2. Click on Rearrange Filters.
3. Try to move some items, items are jumping.

#1
The fix was done by Quicksketch here in the Drupal 7 update: #350275: Update to jQuery 1.3.2..... http://drupal.org/node/350275#comment-1307414
To be precise with what's going on is that if you drag an item carefully around, you can have it disappear.
===================================================================
RCS file: /cvs/drupal/drupal/misc/tabledrag.js,v
retrieving revision 1.23
diff -u -r1.23 tabledrag.js
--- misc/tabledrag.js 18 Feb 2009 13:46:52 -0000 1.23
+++ misc/tabledrag.js 2 Mar 2009 06:52:15 -0000
@@ -206,7 +206,7 @@
self.rowObject = new self.row(item, 'mouse', self.indentEnabled, self.maxDepth, true);
// Save the position of the table.
- self.table.topY = self.getPosition(self.table).y;
+ self.table.topY = $(self.table).offset().top;
self.table.bottomY = self.table.topY + self.table.offsetHeight;
// Add classes to the handle and row.
@@ -486,31 +486,6 @@
};
/**
- * Get the position of an element by adding up parent offsets in the DOM tree.
- */
-Drupal.tableDrag.prototype.getPosition = function(element){
- var left = 0;
- var top = 0;
- // Because Safari doesn't report offsetHeight on table rows, but does on table
- // cells, grab the firstChild of the row and use that instead.
- // http://jacob.peargrove.com/blog/2006/technical/table-row-offsettop-bug-i... if (element.offsetHeight == 0) {
- element = element.firstChild; // A table cell.
- }
-
- while (element.offsetParent){
- left += element.offsetLeft;
- top += element.offsetTop;
- element = element.offsetParent;
- }
-
- left += element.offsetLeft;
- top += element.offsetTop;
-
- return {x:left, y:top};
-};
-
-/**
* Get the mouse coordinates from the event (allowing for browser differences).
*/
Drupal.tableDrag.prototype.mouseCoords = function(event){
@@ -528,9 +503,9 @@
* element. To do this we need the element's position and the mouse position.
*/
Drupal.tableDrag.prototype.getMouseOffset = function(target, event) {
- var docPos = this.getPosition(target);
+ var docPos = $(target).offset();
var mousePos = this.mouseCoords(event);
- return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
+ return { x: mousePos.x - docPos.left, y: mousePos.y - docPos.top };
};
/**
@@ -547,16 +522,8 @@
for (var n=0; n<rows.length; n++) {
var row = rows[n];
var indentDiff = 0;
- // Safari fix see Drupal.tableDrag.prototype.getPosition()
- if (row.offsetHeight == 0) {
- var rowY = this.getPosition(row.firstChild).y;
- var rowHeight = parseInt(row.firstChild.offsetHeight)/2;
- }
- // Other browsers.
- else {
- var rowY = this.getPosition(row).y;
- var rowHeight = parseInt(row.offsetHeight)/2;
- }
+ var rowY = $(row).offset().top;
+ var rowHeight = parseInt($(row).outerHeight()) / 2;
// Because we always insert before, we need to offset the height a bit.
if ((y > (rowY - rowHeight)) && (y < (rowY + rowHeight))) {
@@ -568,6 +535,13 @@
}
}
}
+ else {
+ // Do not allow a row to be swapped with itself.
+ if (row == this.rowObject.element) {
+ return null;
+ }
+ }
+
// Check that swapping with this row is allowed.
if (!this.rowObject.isValidSwap(row)) {
return null;
#2
I'm using 6.x-2.x-dev (Apr 23), and it looks like the above change is actually implemented in the module's version of tabledrag. But I'm still getting the crazy jumping when I'm trying to drag and drop my views fields, filters, etc. Any suggestions?
#3
Yes, I can confirm that.
I've applied changes to jquery_update\replace\tabledrag.js and still there is a problem.
#4
What about this one here: #452376: jQuery 1.3.x (Problem replacing modified version of tabledrag.js)
#5
Can confirm I noticed the same bug. I did figure out how to move them for the time being. Which is the following:
- Drag item like you would do normally (yes with the jumping around)
- Drag it till you are sure you can see it and it is at the correct place
- at this moment click twice to let go of the item and it stays in the spot
Its note very convenient, but heck, while developing you'll do anything to keep going :P
#6
Subscribing
#7
subscribing