Loading ...
Sorry, an error occurred while loading the content.

2719Re: Question regarding swapping of DDPlayers

Expand Messages
  • Hookem
    Jun 30, 2006
    • 0 Attachment
      Spoke to soon. I've now assigned initial players (<div>) to each
      target (<td>), and for the most part, they all swap correctly.
      However, I've noticed certain permutations cause the swapping
      feature to shut down, leaving the dragged object resting over the
      drop target's current player.

      For instance, if I drag the div from td2 up to td1, both players
      swap correctly. If I again drag the div form td2 to td1, they again
      swsap correctly. But once I've done this, if I drag the div from
      td1 to td2, the div in td1 just sits on top of the div in td2 with
      td1 showing a big, empty slot.

      This is what I've added to the init function:

      slots[0].player = players[0];
      slots[1].player = players[1];
      slots[2].player = players[2];
      slots[3].player = players[3];
      slots[4].player = players[4];
      slots[5].player = players[5];
      slots[6].player = players[6];
      slots[7].player = players[7];

      And this is the log that shows the results of the moves:

      Successful swap:
      oDD = td1
      oDD.player = YAHOO.util.DragDrop {div1}
      this.slot = null
      el = div2

      Unsuccessful swap:
      oDD = td2
      oDD.player = YAHOO.util.DragDrop {div2}
      this.slot = YAHOO.util.DragDrop {td1}
      el = div2









      --- In ydn-javascript@yahoogroups.com, "Hookem" <texasataustin@...>
      wrote:
      >
      > Very good, thanks!
      >
      > --- In ydn-javascript@yahoogroups.com, Adam Moore <adamoore@>
      > wrote:
      > >
      > > On Thu, Jun 29, 2006 at 05:26:09PM -0000, Hookem wrote:
      > > > I have a group of cells that are defined as drop targets.
      > > >
      > > > Inside those cells are individual divs defined as players.
      > > >
      > > > I've noticed that after initial loading of the page, I can
      drag
      > a
      > > > player over to one of the drop targets (which already hosts a
      > > > player, mind you), and all that's accomplished is the player
      > settles
      > > > over the player that's already there. No swapping of players
      > > > occurs. However, after that initial sequence, any successive
      > > > dragging and dropping of the two players on their respectice
      > targets
      > > > causes the players to swap correctly.
      > > >
      > > > So it appears there's a problem on initialization whereby the
      > drop
      > > > target doesn't realize a player resides inside of it, so that
      > when
      > > > another player is dragged over it, it doesn't know to swap
      them.
      > > >
      > > > Does anyone know how to resolve this problem?
      > > >
      > > > Here's the js code I have:
      > > >
      > > > slots[0] = new YAHOO.util.DDTarget("td1", "slots");
      > > > slots[1] = new YAHOO.util.DDTarget("td2", "slots");
      > > > slots[2] = new YAHOO.util.DDTarget("td3", "slots");
      > > > slots[3] = new YAHOO.util.DDTarget("td4", "slots");
      > > > slots[4] = new YAHOO.util.DDTarget("td5", "slots");
      > > > slots[5] = new YAHOO.util.DDTarget("td6", "slots");
      > > > slots[6] = new YAHOO.util.DDTarget("td7", "slots");
      > > > slots[7] = new YAHOO.util.DDTarget("td8", "slots");
      > > > players[0] = new YAHOO.example.DDPlayer("div1", "slots");
      > > > players[1] = new YAHOO.example.DDPlayer("div2", "slots");
      > > > players[2] = new YAHOO.example.DDPlayer("div3", "slots");
      > > > players[3] = new YAHOO.example.DDPlayer("div4", "slots");
      > > > players[4] = new YAHOO.example.DDPlayer("div5", "slots");
      > > > players[5] = new YAHOO.example.DDPlayer("div6", "slots");
      > > > players[6] = new YAHOO.example.DDPlayer("div7", "slots");
      > > > players[7] = new YAHOO.example.DDPlayer("div8", "slots");
      > >
      > > Hookem, in the example you are working from, the targets have a
      > property
      > > called player that is used to determine what, if anything, needs
      > to be
      > > swapped when a player is dropped on it. If you are initializing
      > the page
      > > with a slot occupied, you need to make sure you set that
      property.
      > >
      > > -Adam
      > >
      >
    • Show all 5 messages in this topic