Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #3345 (reopened defect)

Opened 3 years ago

Last modified 6 months ago

In IE6, changes to checkbox settings lost when the containing <li> dragged

Reported by: mstewart@gwsmail.com Assigned to: thomas@fesch.at
Priority: high Milestone:
Component: script.aculo.us Version:
Severity: normal Keywords: sortable
Cc:

Description

I have an unordered list defined as a Sortable. It contains list items, each of which contain a checkbox and a text field.

In IE6, if I drag any of these list items, the checkbox reverts back to the value it had at page load time. If I click on a checkbox to change its setting, and then I drag the containing list item, I can see the checkbox either lose or acquire the checkmark as the item is dragged, depending on what it's value was at page load time.

You can reproduce the problem using the functional test dragdrop3_test.html, if you enable its checkbox.

I see this problem in IE6, but not Mozilla or Firefox. I encounter the problem in both version 1.5.0 and 1.5.1 of scriptaculous.

Change History

02/09/06 16:35:21 changed by MrBester

Problem traced to Sortable.onHover:

  dropon.parentNode.insertBefore(element, xxx);

where xxx depends on the direction of drag: up = dropon (overlap > 0.5), down = nextElement.

Alerting element.innerHTML before and after shows IE reverting to original code, however FF shows the original regardless (but still works). Bug does not occur in Opera 8.51 either (Safari unknown).

Proposed patch: add var and check to onHover:

    onHover:function(element, dropon, overlap) {
      var oldParentNode, elHTML=element.innerHTML;
      .
      .
      . // rest of function
      .
      .
      if (element.innerHTML !== elHTML){
        element.innerHTML = elHTML;
      }
    },

03/03/06 17:49:52 changed by anonymous

Proposed patch seems to make the element non-draggable once moved around in IE.

01/17/07 19:15:23 changed by albion

  • status changed from new to closed.
  • resolution set to untested.

hey, i think ive got a solution to this bug. basically on the startDrag event, you get all the checkbox's in the element you are dragging and put them in an array along with its check state then on the updateDrag event you update the values of each check box. here is what it looks like:

cbstate: [],

getElementsByType: function(element,type){

var ele = Form.getElements(element); var returnArr = new Array(); ele.each(function(e){if(e.type==type)returnArr.push(e)}); return returnArr;

},

startDrag: function(event) {

this.dragging = true;

cbstate = new Array(); this.getElementsByType(this.element, 'checkbox').each(function(e){cbstate.push({cb:e,s:e.checked})});

. . . // rest of function . .

},

updateDrag: function(event, pointer) {

if(!this.dragging) this.startDrag(event);

cbstate.each(function(e){e.cb.checked = e.s;});

. . . // rest of function . .

},

i have tested this in ie & firefox and seems to work fine. hope this helps, jamie

01/18/07 09:10:03 changed by albion

  • status changed from closed to reopened.
  • resolution deleted.

03/16/07 15:43:48 changed by tmacedo

The fix works for me.

12/24/07 11:50:45 changed by gobizzer

Updating function "updateDrag" did not work for me so i updated function "finishDrag" and it works just fine