Forum: Ruby on Rails Capturing the position of a draggable element

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Jeannie L. (Guest)
on 2006-01-14 00:53
I would like to capture the position of a draggable element after it's
being dragged, but I am running into problem using several options, such
as "change", "revert" and "onEnd".  My callback handler would only fire
when the page loads, and not when the element is dragged. How can I make
this happen?

 <script src="/scriptaculous-js-1.5.1/lib/prototype.js"
 <script src="/scriptaculous-js-1.5.1/src/scriptaculous.js"
 <table id="a">
<script type ="text/javascript" language="javascript">
 new Draggable('a',{onEnd:alert(this)});
Douglas L. (Guest)
on 2006-01-14 17:45
(Received via mailing list)
2006/1/13, jeannie lu <removed_email_address@domain.invalid>:
> <script type ="text/javascript" language="javascript">
>  new Draggable('a',{onEnd:alert(this)});
> </script>

What that does, is assign the return value of "alert(this)" (probably
false or something) to options.onEnd. A simple way to do what you want
would be:

<script type ="text/javascript" language="javascript">
  new Draggable('a',{endeffect:function(){alert(this)}});

but a more powerful solution would be to create your own object to
handle the dragging, which would look something like this:

var MyDraggable = Class.create();
MyDraggable.prototype = {

    initialize: function (element, options) {
      // drag and drop
      new Draggable(element, options);

    onEnd: function () {

    // your code here



This topic is locked and can not be replied to.