Hi all,
My javascript knowledge is very basic and I need some help.
I''ve used Scriptaculous''s excellent Sortables to create a list
like
so:
<ul id="sortableList">
<li id="item_1">something</li>
<li id="item_2">something else</li>
<li id="item_3">etcetera...</li>
</ul>
<script type="text/javascript">
// <![CDATA[
Sortable.create(''sortableList'',{tag:''li''});
// ]]>
</script>
This is all working fine but I need to fire off 2
''Effect.Highlight''s.
1 at the start of the item drag and one when the item is dropped.
I notice that Draggables provides us with onStart() and onEnd() which
are the perfect events to fire off the highlights...
However, I have no idea how to access these events and need some
advice on how to do so. Some example script with the above sortables
would make my day! :)
Many thanks
Robert
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Robert_F
2007-Mar-22 20:22 UTC
Re: Need help accessing ''Draggable Observers'' with Sortables
Forgot to mention that I got the info about the events from here: http://wiki.script.aculo.us/scriptaculous/show/Draggables --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve
2007-Mar-23 09:26 UTC
Re: Need help accessing ''Draggable Observers'' with Sortables
Hey Robert,
Register an observer:
Draggables.addObserver({
onStart: function(event, draggable) {
new Effect.Highlight(draggable.element);
},
onEnd: function(event draggable) {
new Effect.Highlight(draggable.element);
}
});
Note, however, that Sortables has a onUpdate callback that will trigger
when the elements have just been reordered, which could replace your
generic onEnd callback.
--
Christophe Porteneuve aka TDD
tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Robert_F
2007-Mar-23 11:17 UTC
Re: Need help accessing ''Draggable Observers'' with Sortables
Thank you Christophe! I now have access to the events but draggable.element doesn''t reference the draggable. Is it because I am using sortables? Both events are firing perfectly, how do I get the items correct reference? Firebugs report: draggable has no properties [Break on this error] new Effect.Highlight(draggable.element); Robert PS. I was slightly thrown when I kept receiving an error after trying your code for the first time but then realized that there was a missing comma in onEnd: function(event draggable) :) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve
2007-Mar-23 11:39 UTC
Re: Need help accessing ''Draggable Observers'' with Sortables
Hey, Robert_F a écrit :> Firebugs report: > draggable has no properties > [Break on this error] new Effect.Highlight(draggable.element);No time just now, but just put a breakpoint in your listener functions using Firebug''s script debugger, and look at its local variables view to inspect the arguments. You''ll probably find what you need. -- Christophe Porteneuve aka TDD tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Robert_F
2007-Mar-23 11:51 UTC
Re: Need help accessing ''Draggable Observers'' with Sortables
I don''t know firebug that well, thanks for your help anyway. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---