It would be very best of you if you just maid an example. 'Couse it's
kind of confusing ))

Thanks, Yan

> Well thats the easy part believe it or not....
>
> the container should have the table name in the id or classname somewhere
> then that can be pushed to the request.......... (problem one taken care
> of)!!
>
> Problem 2 - copying rows ....
>
> I would arrange my database something like this.....
>
> id | parent_id | order | content
>
> then the rows perhaps look like this .....
>
> id = '1' , parent_id='abcdefg', order=1, content='The item text / content'
> id = '2' , parent_id='abcdefg', order=2, content='The item text / content'
> id = '3' , parent_id='abcdefg', order=3, content='The item text / content'
> id = '4' , parent_id='abcdefg', order=4, content='The item text / content'
> id = '5' , parent_id='abcdefg', order=5, content='The item text / content'
>
> this is 5 items in the dropzone.....
>
> So you dont need to worry about unique ID as parent ID is unique and takes
> care of it.... (they sit in the database as unique rows anyway due to the
> content placement order)...
>
> On the php backend  you should recieve from the Ajax Request....
>
> parent_id, element_id-> (json array), content...
>
> parent_id gives u the table name and the parent_id ... example
> parent_id="table_name-abcdefg"... exploded on "-" .. tablename is [0],
> parents_id=[1]...
>
> then.... MYSQL -> DELETE FROM $tablename WHERE parent_id=$parents_id ....
> (removes all of the elements)
>
> then ....
>
> Loop the Json array to get the order and the content and....
>
> MYSQL -> INSERT INTO $tablename (`parent_id`,`order`,`content`) VALUES
> ('$parents_id','$the_ID_part_of_the_json_array','$the_CONTENT_part_of_the_json_array');
>
> Now your thinking of how to send the Json Array to the php with all of the
> info needed to insert !!!...
>
> Well thats just done in a loop on classnames of the items in the list as
> explained in a previous post
>
> onDrop: { // not sure of the syntax as its been a while!!
> var i=1;
> var data={};
> $$('.someclass').each(function(e) {
>  var parent_id=$(e).up(1); // get the parent container
>  $(e).id=parent_id+'-'+i; //
> data[i]=parent_id+'-'+i+$(e).innerHTML // can be changed
>
> var jsonarray=Object.toJSON(data);
> // do the ajax request and send jsonarray to php to decode as normal ... on
> the php end you will have parent_id-element_id-element_contents
> ([0],[1],[2]).. after exploding on "-" .. so you foreach the json array on
> the php end and explode each itteration....
>
> // now everything is stored in a json array parsable on the php end.....
> // as the ID is set add things to array
> i++;
>
> });
> }
>
> If this makes no sense i will write it for you if you give me the table
> names and the schema .. or i can write an example for you 2morrow and give
> you the sourcecode
>
> HTH
>
> ALex
>
> ----- Original Message -----
> From: "WLQ" <maybe...@gmail.com>
> To: "Prototype & script.aculo.us" <prototype-scriptaculous@googlegroups.com>
> Sent: Friday, May 29, 2009 1:48 PM
> Subject: [Proto-Scripty] Re: MySQL - order ID
>
> Yes, but also both of the sortables lists are driven by MySQL
> database, by different "tables". Basically the question is how can it
> know between which items the item is dropped. And when it's done that
> it must copy an item (MySQL row) from one MySQL table to another, and
> also change it's ID's to the necessary ones.
>
> > To be honest i dont understand what Walter is trying to say.......
>
> > for example "drag an unlimited number of
> > copies from the first list into the second list, and have the
> > dropped
> > elements keep their place in the second list while the first list
> > remains exactly the same"... means the same to me....
>
> > Let me see if i can break it down and you tell me if i am right.. then we
> > can get moving......
>
> > You have 2 or more lists lets call them containers with
> > draggable,sortable,droppable items from 1 to another ....
> > <!-- DRAG FROM HERE -->
> > <div id="template">
> > <li>Item</li>
> > <li>Item</li>
> > </div>
> > <!--DROP IN HERE -->
> > <div id="template-dropzone">
> > <li>Item</li>
> > <li>Item</li>
> > </div>
>
> > When an item is dragged from $('template') and dropped into
> > $('template-dropzone') .. you want it to revert back to $('template') (i.e
> > just a copy of it to land in the dropzone) and for that new item in the
> > dropzone to have a new ID based on its order .... for example if you had 2
> > items in drop zone (id's 1&2) and you dropped an item in between then then
> > the new item would be ID#2 and the other 2 would be ID#1 & ID#3
> > respectivley... or if you dropped on the end of the list the new item
> > would
> > become ID#3 .... and so on..... am i on the ball so far ?
>
> > If i am then i maintain that its not as hard as you think it is
>
> > If not please point out where i am missing
>
> > Thanks
> > Alex
>
> > ----- Original Message -----
> > From: "WLQ" <maybe...@gmail.com>
> > To: "Prototype & script.aculo.us"
> > <prototype-scriptaculous@googlegroups.com>
> > Sent: Friday, May 29, 2009 1:25 PM
> > Subject: [Proto-Scripty] Re: MySQL - order ID
>
> > I think Walter has given a very nice explanation on what I want.
>
> > "What WLQ is trying to do is
> > have two lists of things, be able to drag an unlimited number of
> > copies from the first list into the second list, and have the
> > dropped
> > elements keep their place in the second list while the first list
> > remains exactly the same. "
>
> > "What WLQ would like (what I would like, too) is something more
> > direct.
> > A set of draggable options that can be dragged into a sortable,
> > revert
> > back to their parent, and leave a clone behind in the position
> > within
> > the list where they were dropped."
>
> > do you get it Alex?
> > If so try to give some more explanation on how it can be done.
>
> > On May 29, 2:15 pm, "Alex McAuley" <webmas...@thecarmarketplace.com>
> > wrote:
> > > you dont need a grid... you can the id is that of the ones above plus 1
> > > ...
>
> > > This will not work properly due to ID's conflicting ....
>
> > > Each time an element is dropped you will need to re-assign id's to each
> > > element...... something like this ...
>
> > > <div id="container-1"> <!-- Droppable -->
> > > <li>Item</li>
> > > <li>Item</li>
> > > <li>Item</li>
> > > <li>Item</li>
> > > <li>Item</li>
> > > <li>Item</li>
> > > </div>
>
> > > onDrop: { // not sure of the syntax as its been a while!!
> > > var i=1;
> > > $$('.someclass').each(function(e) {
> > > var parent_id=$(e).up(1); // get the parent container
> > > $(e).id=parent_id+'_'+i; // gives the new id with using above example
> > > the id's of the Items would be "container-1_1", "container-1_2" and so
> > > on...
> > > then on the php end you can easily parse the id's with explode()/split()
> > > and
> > > force mysql t use those id's should you need to
> > > i++;
>
> > > });
> > > }
>
> > > If this is still not what you are looking for .. then please explain
> > > exactly
> > > what it is you are trying to do as the original question seems to be
> > > missing
> > > from this thread
>
> > > Alex
>
> > > ----- Original Message -----
> > > From: "WLQ" <maybe...@gmail.com>
> > > To: "Prototype & script.aculo.us"
> > > <prototype-scriptaculous@googlegroups.com>
> > > Sent: Friday, May 29, 2009 12:32 PM
> > > Subject: [Proto-Scripty] Re: MySQL - order ID
>
> > > What I can't understand Walter is why have we written 27 messages
> > > about anything which is not related to the question. And have spend on
> > > that nearly a month not getting even closer to the answer. See
> > > misunderstanding lead us to write answers that we don't need.
>
> > > But what I think now is: if we can't do that in scriptaculous or
> > > prototype alone, maybe we can try to find some workaround. Like for
> > > example some kind of javascript grid, or point tracker. I don't know,
> > > just so we can say that if you drop an item on line 2, then ID must be
> > > that, on line 4 then ID must be that. That's the only workaround I
> > > think can be found. So maybe we should focus to find something like
> > > that, instead of looking inside of scriptaculous, that does not do
> > > such a thing?
>
> > > On May 28, 7:25 pm, WLQ <maybe...@gmail.com> wrote:
> > > > Seems like it's too complicated to be done. lol
>
> > > > On May 28, 6:58 pm, Walter Lee Davis <wa...@wdstudio.com> wrote:
>
> > > > > A Sortable is a special case combination of a Draggable and a
> > > > > Droppable. A Sortable may be dragged into another Sortable as long
> > > > > as
> > > > > both lists include the other in their "containment" property. But
> > > > > there is no equivalent to Draggable's revert in a Sortable.
>
> > > > > In my work, I found that while you could drop a draggable onto a
> > > > > sortable, you couldn't get the dropped element to join the sortable
> > > > > explicitly. I took a run up this mountain a couple of months ago,
> > > > > and
> > > > > the best I was able to do was to make a set of draggables, wrap the
> > > > > sortable in a parent which I made droppable, and set revert to true
> > > > > on
> > > > > those draggables. On a successful drop, I would generate a new
> > > > > element, insert it into the sortable, re-initialize the sortable,
> > > > > and
> > > > > then the user would need to drag the new element into position
> > > > > within
> > > > > the list.
>
> > > > > What WLQ would like (what I would like, too) is something more
> > > > > direct.
> > > > > A set of draggable options that can be dragged into a sortable,
> > > > > revert
> > > > > back to their parent, and leave a clone behind in the position
> > > > > within
> > > > > the list where they were dropped. This is not possible as far as
> > > > > I've
> > > > > been able to do it.
>
> > > > > Getting the unique ID either from Prototype or MySQL is trivial, and
> > > > > not really the actual problem here.
>
> > > > > Walter
>
> > > > > On May 28, 2009, at 12:11 PM, Alex McAuley wrote:
>
> > > > > > Also .. isnt there ghosting or "revert" on droppables to make the
> > > > > > elements
> > > > > > go back into the container of which they were dragged from .... If
>
> ...
>
> read more »
--~--~---------~--~----~------------~-------~--~----~
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 prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to