Hello again,

I've worked out where my problem is..

When I've moved an item from the, in this case, hanger to the cargo
(as in dragged an item from my "hanger" box to my "cargo" box) it
create and item, removes it from the Hanger.. and appends it to the
cargo.  However, when it appends it to the cargo, it's still saying
it's a "hanger" item (as in, it's still a $('li',$Hanger).draggable,
rather than now being something in the cargo lot).

Any ideas on how to get it to be associated with the cargo draggables,
rather than the hanger?

I've attached the relevant code below.

Regards,
Paul


// let the Hanger items be draggable
                $('li',$Hanger).draggable({
                        cancel: 'a.ui-icon',// clicking an icon won't initiate 
dragging
                        revert: 'invalid', // when not dropped, the item will 
revert back
to its initial position
                        helper: 'clone',
                        cursor: 'move',
                        zIndex: 10000,
                        appendTo: 'body',
                        start: function() {
                                 $(this).data("location", "Hanger");
                                 ToSystemChat("\nHanger thread : " + 
$(this).data("location"));
                        }
                });

 // let the Cargo be droppable, accepting the Hanger items
                $Cargo.droppable({
                        accept: '#Hanger  li',
                        drop: function(ev, ui) {
                                if (ui.draggable.data("location") == "Hanger")
                                {
                                        ToSystemChat("Start Loc : " + 
ui.draggable.data("location"));
                                        if 
((parseInt(PlayerDetails.ShipDetails.CurrentCargoAmount) +
parseInt($(ui.draggable).attr("No"))) <=
PlayerDetails.ShipDetails.CargoCapacity)
                                        {
                                                
PlayerDetails.ShipDetails.CurrentCargoAmount = parseInt
(PlayerDetails.ShipDetails.CurrentCargoAmount) + parseInt($
(ui.draggable).attr("No"));
                                                CurrentHangerAmount = 
parseInt(CurrentHangerAmount) - parseInt($
(ui.draggable).attr("No"));
                                                TransferCargo("Hanger", 
ui.draggable, $(ui.draggable).attr
("id"), PlayerDetails.CharacterShipID, "1");
                                                
document.getElementById("CargoCapacity").height = ssBarSize -
(((PlayerDetails.ShipDetails.CurrentCargoAmount/
PlayerDetails.ShipDetails.CargoCapacity)*100)*ssBarSizeSegment);
                                                
document.getElementById("HangerCapacity").height = ssBarSize -
(((CurrentHangerAmount/HangerSize)*100)*ssBarSizeSegment);
                                        } else {
                                                alert("not enough room");
                                        };
                                };
                        }
                });

// Move to Cargo function
        function MoveToCargo($item) {
                ToSystemChat("Location : " + $item.data("location"));
                var $Hanger = $('#Hanger'), $Cargo = $('#Cargo');
                $item.data("location", "Cargo");
                $item.fadeOut(function() {
                        $item.data("location", "Cargo");
                        $item.appendTo($Cargo).fadeIn();
                        CargoHanger();
                });
        };


On Mar 28, 6:23 pm, Paul Hutson <[email protected]> wrote:
> Richard, thank you very very much - I realise, looking up through the
> code again, that I was being a bit thick with that last message!
>
> On Mar 27, 3:01 pm, "Richard D. Worth" <[email protected]> wrote:
>
>
>
> > Set a new value when it's in a new place
>
> > $item.data("location", "newValue")
>
> > - Richard
>
> > On Fri, Mar 27, 2009 at 10:57 AM, Paul Hutson
> > <[email protected]>wrote:
>
> > > Richard,
>
> > > Fantastic - just what I was looking for!
>
> > > I now know where the item starts.. however, when it gets to the new
> > > location.. how do I reassociate the item with it's new home.. it seems
> > > to copy across the information.
>
> > > I'm using the following code to move the item :
>
> > >        // Move to Cargo function
> > >        function MoveToCargo($item) {
> > >                var $Hanger = $('#Hanger'), $Cargo = $('#Cargo');
> > >                $item.fadeOut(function() {
> > >                        $item.appendTo($Cargo).fadeIn();
> > >                        $item.data("location") == "Cargo";  //this was how
> > > I've been trying
> > > to reassociate it.. but no joy.
> > >                });
> > >        };
>
> > > Any ideas?
>
> > > Tia,
> > > Paul
>
> > > On Mar 27, 11:02 am, "Richard D. Worth" <[email protected]> wrote:
> > > > Something like this, perhaps?
>
> > > > $("#draggable").draggable({
> > > >   start: function() {
> > > >     $(this).data("location", "RIGHTBOX");
> > > >   }});
>
> > > > $("#droppable").droppable({
> > > >   drop: function(event, ui) {
> > > >     alert(ui.draggable.data("location"));
> > > >   }
>
> > > > });
>
> > > > - Richard
>
> > > > On Fri, Mar 27, 2009 at 4:58 AM, Paul Hutson <
> > > [email protected]>wrote:
>
> > > > > Thanks for the reply Shedokan.. I'm not quite sure I'm following you
> > > > > though. ... when I say the origin, I want to - upon clicking on an
> > > > > item, assign it with a start location variable (scope, or something
> > > > > else.. with say a value of "RIGHTBOX") then when I drop it somewhere I
> > > > > want to be able to read that variable back...
>
> > > > > Any ideas on that front?
>
> > > > > TIA,
> > > > > Paul Hutson
>
> > > > > On Mar 26, 11:44 pm, Shedokan <[email protected]> wrote:
> > > > > > If your'e calling it inside a function of the draggable so you can
> > > use
> > > > > > $(ui.draggable).draggable('option', 'scope') because there is no
> > > > > > ui.draggable
>
> > > > > > alose if you mean that you want to get the left and top position you
> > > > > > can use ui.offset.
>
> > > > > > On 26 מרץ, 16:57, Paul Hutson <[email protected]> wrote:
>
> > > > > > > As a bit of an addon... the thing I really want to do is find out
> > > > > > > draggable objects origin location is.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery UI" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to