Ok this onDrop function does the following:
$result = $this->mMysqli->query('INSERT INTO #1sortable SELECT * FROM
#2sortable WHERE id="' .
$content . '"');
$updatedList = $this->Build#1();
return $updatedList;
onDrop it's cloning a row from one table to another. It's doing a
MySQl query:
INSERT INTO #1sortable (inserts a row of the dropped item (my sortable
is driven by MySLQ database, so each sortable item has it's own "row"
in the "table") inside of a #1 sortable "table").
SELECT * FROM #2sortable (it selects the row from #2 "table" (the #2
"table" is the second sortable list which is driven by MySQL
database)).
WHERE id="' . $content . (it's what it's copying).
$updatedList = $this->Build#1();
return $updatedList; After cloning is done, the sortable list
updates (rebuilding the list).
On May 28, 3:40 pm, Walter Lee Davis <[email protected]> wrote:
> I have not been able to get this to work the way you describe. What I
> had to do was set up my "factory" elements as Draggable (with revert)
> and then set a separate Droppable container around my sortable. When I
> drop, the onDrop function fires, which does the Ajax call to create a
> new element, then that element is appended to the end of the sortable
> and the sortable is re-initialized so that it recognizes the new member.
>
> I understand what you want to do, but I wasn't able to make it work
> precisely the way you describe it here.
>
> One thing for you to think over as you work on this is to do less. For
> example:
>
> > $result = $this->mMysqli->query('INSERT INTO tasks SELECT *
> > FROM channels WHERE id="' .
> > $content . '"');
> > $updatedList = $this->BuildPlaylist();
> > return $updatedList;
>
> I can't see what's going on in here, but if you are returning (and re-
> populating) the entire list, maybe you can simply return the one new
> list element (with its newly generated ID) and insert that into your
> Sortable where you are dropping (which is the part I couldn't figure
> out myself, hence my punt). You do know the new ID after your insert
> -- just get the value from your $result:
>
> $row = mysql_fetch_object($result);
> $id = $row->id;
>
> Build up your element as HTML, and insert it into the outer list with
> Element.insert('theElementYouDroppedAfter',{after:yourHTML});
>
> then just re-run Sortable.create with the same arguments as previous,
> and it will tear down the old Sortable (in memory) and replace it with
> a new one that "knows" what order these things are currently in.
>
> Walter
>
> On May 28, 2009, at 7:13 AM, WLQ wrote:
>
> > After it clones a row from one table to another, the list updates. But
> > I want not only to clone an item, but also give it a corret Id, so
> > it's not somewhere inside of a sortable but exactly where you've
> > dropped it.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" 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/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---