Hi folks, I''m an intermediate JavaScripter and I''m just trying to get my head around the whole OOP thing with mixed levels of success. I need to do certain things in response to user interaction, but I''m not totally sure how or where I attach code. At the moment I''m creating sortable lists, but due to the nature they''re created, I need to add certain parameters / callbacks to the draggables afterwards... don''t I? This is fine with simple mouseup and mousedown using Event.observe(). However, what I want to do is check if the draggable is allowed to be dragged in the first place (some draggables in my list shold be locked from dragging!) and if not, disallow the drag - I presume using draggable''s "revert" property? However, I can''t for the life figure how to set it! I''ve looked through the DOM using Firebug, but I can''t seem to set it directly as it just doesn''t work or it breaks everything. Can someone point out what I should do? Many thanks, Dave --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Dave, It would like like this.You don''t need to use Event.observe: Sortable.create("Alist", {constraint:false, only:''someClass'', onUpdate:function() {saveChanges()}}) function saveChanges() { order = Sortable.serialize(''Alist'') order = order.replace(/flist\[\]=/g, ''''); sortOrder = order.split(''&''); //sortOrder is now an array containing the order of your list } The elements that are draggable would also have a class name of ''someClass'' I hope this helps. - James. On Aug 15, 6:44 am, Dave Stewart <singalongwithd...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> Hi folks, > > I''m an intermediate JavaScripter and I''m just trying to get my head > around the whole OOP thing with mixed levels of success. I need to do > certain things in response to user interaction, but I''m not totally > sure how or where I attach code. > > At the moment I''m creating sortable lists, but due to the nature > they''re created, I need to add certain parameters / callbacks to the > draggables afterwards... don''t I? > > This is fine with simple mouseup and mousedown using Event.observe(). > > However, what I want to do is check if the draggable is allowed to be > dragged in the first place (some draggables in my list shold be locked > from dragging!) and if not, disallow the drag - I presume using > draggable''s "revert" property? > > However, I can''t for the life figure how to set it! I''ve looked > through the DOM using Firebug, but I can''t seem to set it directly as > it just doesn''t work or it breaks everything. > > Can someone point out what I should do? > > Many thanks, > Dave--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Diodeus, Yup - giving the draggables the correct class worked! I was so busy with other stuff I must have overlooked that - thanks! I''m still interested to know how I set handlers on objects AFTER creation though, as it''s very useful for other things. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---