Hi, Forgive me if this has been discussed/resolved before. I have done a search of both this mailing list and the web, but I can''t find a solution to my problem (which is odd as I would think plenty of people would have the same requirement and therefore the same problem). Basically, I have a OL of "Questions". Each question has an OL of "Answers". The user needs to be able to order the questions and also the answers within each question. Here is some HTML and script that demonstrates the issue: <ol id="questionList1" class="questionsList"> <li class="question" id="question1"> <span class="questionTitle">Question 1</span> <ol id="answerList1" class="answersList"> <li class="answer">Answer 1</li> <li class="answer">Answer 2</li> </ol> </li> <li class="question" id="question2"> <span class="questionTitle">Question 2</span> <ol id="answerList2" class="answersList"> <li class="answer">Answer 1</li> <li class="answer">Answer 2</li> </ol> </li> </ol> <script type="text/javascript"> Sortable.create("questionList1", {only: "question", handle: "questionTitle"}); Sortable.create("answerList1", {only: "answer"}); Sortable.create("answerList2", {only: "answer"}); </script> By creating a sortable on the sub OL (answersLists), it stops the main questionsList from being sortable (i.e can''t sort questions). If we comment out the Sortable.create for the two answer lists, the main questions sortable works fine. Am I doing something wrong (obviously)? Is it possible to acheive what I need with Sortables? Thanks in advance, Justin _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Scripty 1.6.1 has a sortable tree. You just make a new sortable on the parent list element and pass tree:true in options and it includes all child lists to make one big sortable tree. On 11/07/06, Justin McCormack <jus101-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > Forgive me if this has been discussed/resolved before. I have done a search > of both this mailing list and the web, but I can''t find a solution to my > problem (which is odd as I would think plenty of people would have the same > requirement and therefore the same problem). > > Basically, I have a OL of "Questions". Each question has an OL of "Answers". > The user needs to be able to order the questions and also the answers within > each question. Here is some HTML and script that demonstrates the issue: > > <ol id="questionList1" class="questionsList"> > <li class="question" id="question1"> > <span class="questionTitle">Question 1</span> > <ol id="answerList1" class="answersList"> > <li class="answer">Answer 1</li> > <li class="answer">Answer 2</li> > </ol> > </li> > <li class="question" id="question2"> > <span class="questionTitle">Question 2</span> > <ol id="answerList2" class="answersList"> > <li class="answer">Answer 1</li> > <li class="answer">Answer 2</li> > </ol> > </li> > </ol> > <script type="text/javascript"> > Sortable.create("questionList1", {only: "question", handle: > "questionTitle"}); > Sortable.create("answerList1", {only: "answer"}); > Sortable.create("answerList2", {only: "answer"}); > </script> > > By creating a sortable on the sub OL (answersLists), it stops the main > questionsList from being sortable (i.e can''t sort questions). If we comment > out the Sortable.create for the two answer lists, the main questions > sortable works fine. > > Am I doing something wrong (obviously)? Is it possible to acheive what I > need with Sortables? > > Thanks in advance, > > Justin > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >-- Andrew Tetlaw htp://tetlaw.id.au
Thanks for your reply, but I don''t actually want a tree. I want two independent lists - I don''t want the user to be able to drag answer list items into the question list.. Justin _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
I''ve just run into this problem. It seems that the problem is with Sortables.destroy. If you create a sortable within another sortable then this line of dragdrop.js: // clear any old sortable with same element this.destroy(element); Will actually end up destroying the parent. Put this at the in your code after you include scriptaculous and it should sort it out: Sortable.destroy = function(element){ var s = Sortable.options(element); if(s) { if(element.id == s.element.id) { //Modification. Checks destroying correct element. Draggables.removeObserver(s.element); s.droppables.each(function(d){ Droppables.remove(d) }); s.draggables.invoke(''destroy''); delete Sortable.sortables[s.element.id]; } } } I''m not sure though if this might have any undesirable knock-on effects.. _____ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Justin McCormack Sent: 11 July 2006 11:24 To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] Scriptaculous Sortable within a Sortable Hi, Forgive me if this has been discussed/resolved before. I have done a search of both this mailing list and the web, but I can''t find a solution to my problem (which is odd as I would think plenty of people would have the same requirement and therefore the same problem). Basically, I have a OL of "Questions". Each question has an OL of "Answers". The user needs to be able to order the questions and also the answers within each question. Here is some HTML and script that demonstrates the issue: <ol id="questionList1" class="questionsList"> <li class="question" id="question1"> <span class="questionTitle">Question 1</span> <ol id="answerList1" class="answersList"> <li class="answer">Answer 1</li> <li class="answer">Answer 2</li> </ol> </li> <li class="question" id="question2"> <span class="questionTitle">Question 2</span> <ol id="answerList2" class="answersList"> <li class="answer">Answer 1</li> <li class="answer">Answer 2</li> </ol> </li> </ol> <script type="text/javascript"> Sortable.create("questionList1", {only: "question", handle: "questionTitle"}); Sortable.create("answerList1", {only: "answer"}); Sortable.create("answerList2", {only: "answer"}); </script> By creating a sortable on the sub OL (answersLists), it stops the main questionsList from being sortable (i.e can''t sort questions). If we comment out the Sortable.create for the two answer lists, the main questions sortable works fine. Am I doing something wrong (obviously)? Is it possible to acheive what I need with Sortables? Thanks in advance, Justin _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs