views:

64

answers:

1

probably best if i first just write my code down. i have:

<li class="sorted" id='<%= domid %>'>
    <%= horse.name %>
</li>
<%= draggable_element(domid, :ghosting=>true) %>

after the drop on some "box" the draggable element with name = horse.name stays on it. i want to delete it(the name). i was trying different things.

supposedly i will have to write plain javascript(i am not sure if thats the case but) if i do that i have problems with getting the parent element id that i have to insert in js.

var mydrag = new Draggable(domid, { ghosting: true });
// then destroy it when you don't need it anymore
mydrag.destroy();

how can i get proper domid. sth like this.parentNode.id? i also tried

 <%= draggable_element(domid, :ghosting=>true, :endeffect => "this.hide();") %>

without success.

so my question is how to remove the element after drag?

+1  A: 

You can use endeffect, like this:

var mydrag = new Draggable(domid, { ghosting: true, endeffect:function() { $(domid).hide() } });
Diodeus
i can only try your version like this: <%= draggable_element(domid, :ghosting=>true, :endeffect => "function() { $(#{domid}).hide() }" ) %>because i cant get the variable(!domid!) that represents parent dom element of draggable into javascript.and if i try it like this(with draggable_element rails scriptaculous helper) it really seems to disappear but just for a second. and is then again at my mouse and also on the drop receiving element. i also tried .remove() and .destroy() instead of hide but it doesnt work. thanks for the answer anyway!
actually it is just hidden behind an on hover effect of the droppable element i just noticed. so it is shown again when i go off of it.
I am not familiar with RoR, but you can decalre "domid" as a global variable, then you can access it inside your function.
Diodeus