|
»
»
»
Sortables: issue with parents swapping children with their siblings (nested sorting)
|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
Sortables: issue with parents swapping children with their siblings (nested sorting)What a dysfunctional family! ;] I'm trying to shoot for a drag-and-drop layout manager using sortables. Here's a simplified sketch of what my output might look like: <script type="text/javascript" SRC="contrib/ jquery-1.2.6.js"></script> <script type="text/javascript" SRC="contrib/UI/ui.core.js"></script> <script type="text/javascript" SRC="contrib/UI/ui.sortable.js"></ script> <style> #boxList li { background-color:Khaki;display:block;list-style- type:none;float:left;margin:2px;border:1px solid black;padding: 5px;margin:5px;} </style> <script> $(document).ready(function() { $("#boxElement").sortable({cursor: "move", opacity:.8, connectWith: ["ul"], items : "li" , dropOnEmpty:true }); }); </script> <ul name="boxList" id="boxList"> <li name="boxElement" id="boxElement"> <ul name="boxList" id="boxList"> <li name="boxElement" id="boxElement"> <div style="float:left; width:335px;" class="box" ID="box_1" name="box_1"> box #1 </div> </li> </ul> <ul name="boxList" id="boxList"> <li name="boxElement" id="boxElement"> <div style="float:left; width:335px;" class="box" ID="box_2" name="box_2"> box #2 <ul name="boxList" id="boxList"> <li name="boxElement" id="boxElement"> <div style="float:left; width:280px;" class="box" ID="box_3" name="box_3"> box #3 </div> </li> </ul> <ul name="boxList" id="boxList"> <li name="boxList" id="boxList"> <div style="float:left; width:280px;" class="box" ID="box_4" name="box_4"> box #4 </div> </li> </ul> </div> </li> </ul> </li> </ul> Looking at this, box #3 and #4 are children. Their parent is box #2. Box #1 box #2's sibling. There is an unnamed grandparent, which is the opening <ul>. It has no textual contents of its own, only children. Box 3 and 4 sort fine within their parent. Both parents also sort fine against each other. ISSUE: If I attempt to drag box 3 or 4 to the parent sibling (box 1), they instead stubbornly insist on moving to the grandparent, upon which they seem to act as siblings of box #1 and #2. This is technically fine on one level: I *should* be able to drag the children to their grandparent, BUT, I also want to be able to drag them into their parent's sibling, and be able to sort them there. I've seen plenty of posts regarding nested sortables here, but haven't found anything addressing this particular problem. Sorry if this is redundant. -Adam --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery UI" group. To post to this group, send email to jquery-ui@... To unsubscribe from this group, send email to jquery-ui-unsubscribe@... For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Sortables: issue with parents swapping children with their siblings (nested sorting)> ISSUE: If I attempt to drag box 3 or 4 to the parent sibling (box 1), > they instead stubbornly insist on moving to the grandparent, upon > which they seem to act as siblings of box #1 and #2. > > This is technically fine on one level: I *should* be able to drag the > children to their grandparent, BUT, I also want to be able to drag > them into their parent's sibling, and be able to sort them there. I think this is the same issue that everyone else is having: the sortable item needs to be droppable as well. Apparently it is being worked on at the moment, and if you search the threads here, there is a link to the SVN where you can get the latest builds and mess around with it. -- Josh ----- Original Message ----- From: "hedgomatic" <hedgomatic@...> To: "jQuery UI" <jquery-ui@...> Sent: Wednesday, July 16, 2008 9:42 AM Subject: [jquery-ui] Sortables: issue with parents swapping children with their siblings (nested sorting) > > What a dysfunctional family! ;] > > I'm trying to shoot for a drag-and-drop layout manager using > sortables. Here's a simplified sketch of what my output might look > like: > > <script type="text/javascript" SRC="contrib/ > jquery-1.2.6.js"></script> > <script type="text/javascript" SRC="contrib/UI/ui.core.js"></script> > <script type="text/javascript" SRC="contrib/UI/ui.sortable.js"></ > script> > <style> > #boxList li { background-color:Khaki;display:block;list-style- > type:none;float:left;margin:2px;border:1px solid black;padding: > 5px;margin:5px;} > </style> > <script> > $(document).ready(function() { > $("#boxElement").sortable({cursor: "move", opacity:.8, > connectWith: ["ul"], items : "li" , dropOnEmpty:true }); > }); > </script> > <ul name="boxList" id="boxList"> > <li name="boxElement" id="boxElement"> > <ul name="boxList" id="boxList"> > <li name="boxElement" id="boxElement"> > <div style="float:left; width:335px;" class="box" ID="box_1" > name="box_1"> > box #1 > </div> > </li> > </ul> > <ul name="boxList" id="boxList"> > <li name="boxElement" id="boxElement"> > <div style="float:left; width:335px;" class="box" ID="box_2" > name="box_2"> > box #2 > <ul name="boxList" id="boxList"> > <li name="boxElement" id="boxElement"> > <div style="float:left; width:280px;" class="box" ID="box_3" > name="box_3"> > box #3 > </div> > </li> > </ul> > <ul name="boxList" id="boxList"> > <li name="boxList" id="boxList"> > <div style="float:left; width:280px;" class="box" ID="box_4" > name="box_4"> > box #4 > </div> > </li> > </ul> > </div> > </li> > </ul> > </li> > </ul> > > > > Looking at this, box #3 and #4 are children. Their parent is box #2. > > Box #1 box #2's sibling. > > There is an unnamed grandparent, which is the opening <ul>. > It has no textual contents of its own, only children. > > Box 3 and 4 sort fine within their parent. > > Both parents also sort fine against each other. > > ISSUE: If I attempt to drag box 3 or 4 to the parent sibling (box 1), > they instead stubbornly insist on moving to the grandparent, upon > which they seem to act as siblings of box #1 and #2. > > This is technically fine on one level: I *should* be able to drag the > children to their grandparent, BUT, I also want to be able to drag > them into their parent's sibling, and be able to sort them there. > > > > > I've seen plenty of posts regarding nested sortables here, but haven't > found anything addressing this particular problem. Sorry if this is > redundant. > > -Adam > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery UI" group. To post to this group, send email to jquery-ui@... To unsubscribe from this group, send email to jquery-ui-unsubscribe@... For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Sortables: issue with parents swapping children with their siblings (nested sorting)Perhaps the depth of love can be calibrated by the number of different selves that are actively involved in a given relationship. Carl Sagan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery UI" group. To post to this group, send email to jquery-ui@... To unsubscribe from this group, send email to jquery-ui-unsubscribe@... For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Sortables: issue with parents swapping children with their siblings (nested sorting)I thought I could get around the issue by simply throwing down a rule that children can only get sorted inside their parents, but containment:"parent" is somewhat problematic in that there's frequently no room left inside the parent to move anything around (I imagine fixed height and width would fix this, but that's counter to what I'm trying to do.) People mentioned the "layout" feature slated for 1.7, but that sounds like a jQuery version of the YUI toolkit by the same name, which also doesn't have this particular feature...at least not as far as I've seen in their demos. I wonder how combining connectWith along with a start function that disables parent().parent() from being sortable and then re-enables on stop would work.... On Jul 16, 2:35 pm, "Josh Nathanson" <joshnathan...@...> wrote: > > ISSUE: If I attempt to drag box 3 or 4 to the parent sibling (box 1), > > they instead stubbornly insist on moving to the grandparent, upon > > which they seem to act as siblings of box #1 and #2. > > > This is technically fine on one level: I *should* be able to drag the > > children to their grandparent, BUT, I also want to be able to drag > > them into their parent's sibling, and be able to sort them there. > > I think this is the same issue that everyone else is having: the sortable > item needs to be droppable as well. Apparently it is being worked on at the > moment, and if you search the threads here, there is a link to the SVN where > you can get the latest builds and mess around with it. > > -- Josh > > ----- Original Message ----- > From: "hedgomatic" <hedgoma...@...> > To: "jQuery UI" <jquery-ui@...> > Sent: Wednesday, July 16, 2008 9:42 AM > Subject: [jquery-ui] Sortables: issue with parents swapping children with > > their siblings (nested sorting) > > > What a dysfunctional family! ;] > > > I'm trying to shoot for a drag-and-drop layout manager using > > sortables. Here's a simplified sketch of what my output might look > > like: > > > <script type="text/javascript" SRC="contrib/ > > jquery-1.2.6.js"></script> > > <script type="text/javascript" SRC="contrib/UI/ui.core.js"></script> > > <script type="text/javascript" SRC="contrib/UI/ui.sortable.js"></ > > script> > > <style> > > #boxList li { background-color:Khaki;display:block;list-style- > > type:none;float:left;margin:2px;border:1px solid black;padding: > > 5px;margin:5px;} > > </style> > > <script> > > $(document).ready(function() { > > $("#boxElement").sortable({cursor: "move", opacity:.8, > > connectWith: ["ul"], items : "li" , dropOnEmpty:true }); > > }); > > </script> > > <ul name="boxList" id="boxList"> > > <li name="boxElement" id="boxElement"> > > <ul name="boxList" id="boxList"> > > <li name="boxElement" id="boxElement"> > > <div style="float:left; width:335px;" class="box" ID="box_1" > > name="box_1"> > > box #1 > > </div> > > </li> > > </ul> > > <ul name="boxList" id="boxList"> > > <li name="boxElement" id="boxElement"> > > <div style="float:left; width:335px;" class="box" ID="box_2" > > name="box_2"> > > box #2 > > <ul name="boxList" id="boxList"> > > <li name="boxElement" id="boxElement"> > > <div style="float:left; width:280px;" class="box" ID="box_3" > > name="box_3"> > > box #3 > > </div> > > </li> > > </ul> > > <ul name="boxList" id="boxList"> > > <li name="boxList" id="boxList"> > > <div style="float:left; width:280px;" class="box" ID="box_4" > > name="box_4"> > > box #4 > > </div> > > </li> > > </ul> > > </div> > > </li> > > </ul> > > </li> > > </ul> > > > Looking at this, box #3 and #4 are children. Their parent is box #2. > > > Box #1 box #2's sibling. > > > There is an unnamed grandparent, which is the opening <ul>. > > It has no textual contents of its own, only children. > > > Box 3 and 4 sort fine within their parent. > > > Both parents also sort fine against each other. > > > ISSUE: If I attempt to drag box 3 or 4 to the parent sibling (box 1), > > they instead stubbornly insist on moving to the grandparent, upon > > which they seem to act as siblings of box #1 and #2. > > > This is technically fine on one level: I *should* be able to drag the > > children to their grandparent, BUT, I also want to be able to drag > > them into their parent's sibling, and be able to sort them there. > > > I've seen plenty of posts regarding nested sortables here, but haven't > > found anything addressing this particular problem. Sorry if this is > > redundant. > > > -Adam --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery UI" group. To post to this group, send email to jquery-ui@... To unsubscribe from this group, send email to jquery-ui-unsubscribe@... For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Sortables: issue with parents swapping children with their siblings (nested sorting)Hi there, in fact, there's a easy-to-use feature for everyone who wants to decide what their sortable items are individually. Instead of inserting a selector string into the option "items", (i.e. "> li"), insert a function callback, that returns a jquery node list of elements. See the following example: items: function(e, ui) { return $(...); } in the ui object, you have ui.item, which is the currently selected item, and 'this' as always links to the main element. So you can return your individual query what items should be sortable during this call based on the current clicked item. This makes thing possible as "make all levels nested sortable, but only allow sorting in the current container". On Wed, Jul 16, 2008 at 10:01 PM, hedgomatic <hedgomatic@...> wrote:
-- Paul Bakaus UI Architect -- http://paulbakaus.com http://www.linkedin.com/in/paulbakaus --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery UI" group. To post to this group, send email to jquery-ui@... To unsubscribe from this group, send email to jquery-ui-unsubscribe@... For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Sortables: issue with parents swapping children with their siblings (nested sorting)Nice. I was looking in the wrong place: I kept digging through trying to figure out if I could modify the connectWith array. I'm confused on a few levels though. I suspect that I probably want to return an object that is "this" and its siblings. I imagine I'll need an if{} somewhere in there to listen only for click events on <LI>s so that any random nested <P> or <B> aren't also sortable. Even given your perfectly illustrative example and notes though, I'm stumped / totally lost as to what this looks like real-world. I guess I'm also getting confused on all the different options (containment restricts sorting, this items callback restricts sorting, etc) Sorry, I'd RTFM, but I haven't seen anything like this documented yet...if you don't mind hand-holding me a touch more on how I can restrict sorting to within this' current container / parent, I'll gladly add to the wiki with a working example. On Jul 17, 6:15 am, "Paul Bakaus" <paul.bak...@...> wrote: > Hi there, > > in fact, there's a easy-to-use feature for everyone who wants to decide what > their sortable items > are individually. > > Instead of inserting a selector string into the option "items", (i.e. "> > li"), insert a function callback, > that returns a jquery node list of elements. See the following example: > > items: function(e, ui) { > return $(...); > > } > > in the ui object, you have ui.item, which is the currently selected item, > and 'this' as always links to the main element. > So you can return your individual query what items should be sortable during > this call based on the current clicked > item. This makes thing possible as "make all levels nested sortable, but > only allow sorting in the current container". > > > > On Wed, Jul 16, 2008 at 10:01 PM, hedgomatic <hedgoma...@...> wrote: > > > I thought I could get around the issue by simply throwing down a rule > > that children can only get sorted inside their parents, but > > containment:"parent" is somewhat problematic in that there's > > frequently no room left inside the parent to move anything around (I > > imagine fixed height and width would fix this, but that's counter to > > what I'm trying to do.) > > > People mentioned the "layout" feature slated for 1.7, but that sounds > > like a jQuery version of the YUI toolkit by the same name, which also > > doesn't have this particular feature...at least not as far as I've > > seen in their demos. > > > I wonder how combining connectWith along with a start function that > > disables parent().parent() from being sortable and then re-enables on > > stop would work.... > > > On Jul 16, 2:35 pm, "Josh Nathanson" <joshnathan...@...> wrote: > > > > ISSUE: If I attempt to drag box 3 or 4 to the parent sibling (box 1), > > > > they instead stubbornly insist on moving to the grandparent, upon > > > > which they seem to act as siblings of box #1 and #2. > > > > > This is technically fine on one level: I *should* be able to drag the > > > > children to their grandparent, BUT, I also want to be able to drag > > > > them into their parent's sibling, and be able to sort them there. > > > > I think this is the same issue that everyone else is having: the > > sortable > > > item needs to be droppable as well. Apparently it is being worked on at > > the > > > moment, and if you search the threads here, there is a link to the SVN > > where > > > you can get the latest builds and mess around with it. > > > > -- Josh > > > > ----- Original Message ----- > > > From: "hedgomatic" <hedgoma...@...> > > > To: "jQuery UI" <jquery-ui@...> > > > Sent: Wednesday, July 16, 2008 9:42 AM > > > Subject: [jquery-ui] Sortables: issue with parents swapping children with > > > > their siblings (nested sorting) > > > > > What a dysfunctional family! ;] > > > > > I'm trying to shoot for a drag-and-drop layout manager using > > > > sortables. Here's a simplified sketch of what my output might look > > > > like: > > > > > <script type="text/javascript" SRC="contrib/ > > > > jquery-1.2.6.js"></script> > > > > <script type="text/javascript" SRC="contrib/UI/ui.core.js"></script> > > > > <script type="text/javascript" SRC="contrib/UI/ui.sortable.js"></ > > > > script> > > > > <style> > > > > #boxList li { background-color:Khaki;display:block;list-style- > > > > type:none;float:left;margin:2px;border:1px solid black;padding: > > > > 5px;margin:5px;} > > > > </style> > > > > <script> > > > > $(document).ready(function() { > > > > $("#boxElement").sortable({cursor: "move", opacity:.8, > > > > connectWith: ["ul"], items : "li" , dropOnEmpty:true }); > > > > }); > > > > </script> > > > > <ul name="boxList" id="boxList"> > > > > <li name="boxElement" id="boxElement"> > > > > <ul name="boxList" id="boxList"> > > > > <li name="boxElement" id="boxElement"> > > > > <div style="float:left; width:335px;" class="box" ID="box_1" > > > > name="box_1"> > > > > box #1 > > > > </div> > > > > </li> > > > > </ul> > > > > <ul name="boxList" id="boxList"> > > > > <li name="boxElement" id="boxElement"> > > > > <div style="float:left; width:335px;" class="box" ID="box_2" > > > > name="box_2"> > > > > box #2 > > > > <ul name="boxList" id="boxList"> > > > > <li name="boxElement" id="boxElement"> > > > > <div style="float:left; width:280px;" class="box" ID="box_3" > > > > name="box_3"> > > > > box #3 > > > > </div> > > > > </li> > > > > </ul> > > > > <ul name="boxList" id="boxList"> > > > > <li name="boxList" id="boxList"> > > > > <div style="float:left; width:280px;" class="box" ID="box_4" > > > > name="box_4"> > > > > box #4 > > > > </div> > > > > </li> > > > > </ul> > > > > </div> > > > > </li> > > > > </ul> > > > > </li> > > > > </ul> > > > > > Looking at this, box #3 and #4 are children. Their parent is box #2. > > > > > Box #1 box #2's sibling. > > > > > There is an unnamed grandparent, which is the opening <ul>. > > > > It has no textual contents of its own, only children. > > > > > Box 3 and 4 sort fine within their parent. > > > > > Both parents also sort fine against each other. > > > > > ISSUE: If I attempt to drag box 3 or 4 to the parent sibling (box 1), > > > > they instead stubbornly insist on moving to the grandparent, upon > > > > which they seem to act as siblings of box #1 and #2. > > > > > This is technically fine on one level: I *should* be able to drag the > > > > children to their grandparent, BUT, I also want to be able to drag > > > > them into their parent's sibling, and be able to sort them there. > > > > > I've seen plenty of posts regarding nested sortables here, but haven't > > > > found anything addressing this particular problem. Sorry if this is > > > > redundant. > > > > > -Adam > > -- > Paul Bakaus > UI Architect > --http://paulbakaus.comhttp://www.linkedin.com/in/paulbakaus --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery UI" group. To post to this group, send email to jquery-ui@... To unsubscribe from this group, send email to jquery-ui-unsubscribe@... For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Sortables: issue with parents swapping children with their siblings (nested sorting)hedgomatic This is a very similar problem to the one I am having - so I would be very interested in yr solution. I will try Paul's suggestion of using the Items and sticking in a function callback - I have a feeling that might offer me some light. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery UI" group. To post to this group, send email to jquery-ui@... To unsubscribe from this group, send email to jquery-ui-unsubscribe@... For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Sortables: issue with parents swapping children with their siblings (nested sorting)Update: tried a stab in the dark with.... $("li").sortable({cursor: "move", opacity:.8, items:function(e,ui) { return $(this.siblings()); }, dropOnEmpty:true }); and $("li").sortable({cursor: "move", opacity:.8, items:function(e,ui) { return $(this+" ~ li"); }, dropOnEmpty:true }); which I was hoping would grab the currently selected item and any <li> siblings and treat them as a sortable, but these result in nothing being sortable. this: items:function(e,ui) { var siblingList = this.siblings(); alert(siblingList); return $(siblingList); } shows me the proper number of elements based on where I click (objects with 1 sibling alert twice, objects with five siblings alert 6 times, etc.). I also get an alert for every LI when the page loads, So I feel like I'm getting closer there. I tried it as an array as well with no luck. Yet somehow, hilariously, $return("..."); sort of works. Sort of. Still stumped. :/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery UI" group. To post to this group, send email to jquery-ui@... To unsubscribe from this group, send email to jquery-ui-unsubscribe@... For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Sortables: issue with parents swapping children with their siblings (nested sorting)Still messing around with this and totally stumped. Wondering if anyone else has had any luck? On Jul 17, 3:50 pm, hedgomatic <hedgoma...@...> wrote: > Update: tried a stab in the dark with.... > > $("li").sortable({cursor: "move", opacity:.8, items:function(e,ui) > { return $(this.siblings()); }, dropOnEmpty:true }); > and > $("li").sortable({cursor: "move", opacity:.8, items:function(e,ui) > { return $(this+" ~ li"); }, dropOnEmpty:true }); > > which I was hoping would grab the currently selected item and any <li> > siblings and treat them as a sortable, but these result in nothing > being sortable. > > this: > items:function(e,ui) { var siblingList = this.siblings(); > alert(siblingList); return $(siblingList); } > > shows me the proper number of elements based on where I click (objects > with 1 sibling alert twice, objects with five siblings alert 6 times, > etc.). I also get an alert for every LI when the page loads, So I feel > like I'm getting closer there. I tried it as an array as well with no > luck. > > Yet somehow, hilariously, $return("..."); sort of works. Sort of. > Still stumped. :/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery UI" group. To post to this group, send email to jquery-ui@... To unsubscribe from this group, send email to jquery-ui-unsubscribe@... For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=en -~----------~----~----~----~------~----~------~--~--- |
| Free Forum Powered by Nabble | Forum Help |