Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-29-2011, 09:19 AM   PM User | #1
narek
New Coder

 
Join Date: Feb 2010
Location: Armenia
Posts: 41
Thanks: 17
Thanked 0 Times in 0 Posts
narek has a little shameless behaviour in the past
jQuery draggable element jumps back to its initial position

Hello there .
I have some elements on my page that i have apllied jQuery's draggable function to them so I can drag them . Here is my question .
Is there a function which will return the draggable object to its initial position(the position where it was when the page loaded ) when an event occurs (for example I draggeed it and put it in a droppable element ) ?

Please I really need your help!!!
Thank you in advance!!
narek is offline   Reply With Quote
Old 10-29-2011, 11:49 AM   PM User | #2
SB65
Senior Coder

 
Join Date: Feb 2009
Location: West Yorkshire
Posts: 2,827
Thanks: 9
Thanked 685 Times in 679 Posts
SB65 will become famous soon enoughSB65 will become famous soon enough
Not quite clear what you're trying to do, but if you specify

helper:'clone'

as an option for .draggable() then the dragged element will remain where it is and a clone of the element will be dragged - so the original element does not move. Is that what you mean? So this would allow you to build, for example, a shopping cart where you can drag items to the cart but they remain available in the shop for multiple purchases.

Otherwise, the revert option will cause the dragged element to return to it's original position when dragging stops.

Last edited by SB65; 10-29-2011 at 11:51 AM..
SB65 is offline   Reply With Quote
Users who have thanked SB65 for this post:
narek (10-29-2011)
Old 10-29-2011, 01:44 PM   PM User | #3
narek
New Coder

 
Join Date: Feb 2010
Location: Armenia
Posts: 41
Thanks: 17
Thanked 0 Times in 0 Posts
narek has a little shameless behaviour in the past
SB65 your post was really helpfull thank you.
But i miss only one thing here. After i drag the clone and dropp in the appropriate "drop element" how can i make it to disapprear(I mean hide or do watever to make the dragged element to disappear from its initial place ) ? And also how to make the "dragged" element be on the dropped element(since in case of clone it disappears) ?
narek is offline   Reply With Quote
Old 10-29-2011, 05:13 PM   PM User | #4
SB65
Senior Coder

 
Join Date: Feb 2009
Location: West Yorkshire
Posts: 2,827
Thanks: 9
Thanked 685 Times in 679 Posts
SB65 will become famous soon enoughSB65 will become famous soon enough
To do something when the element is dropped it would be usual to write a function against the drop event:

Code:
$('#droppable').droppable({
	drop:function(event,ui){
               .... do things ......
	}
});
So this code could add something into the droppable element or whatever as required.
SB65 is offline   Reply With Quote
Users who have thanked SB65 for this post:
narek (10-29-2011)
Old 10-29-2011, 05:34 PM   PM User | #5
narek
New Coder

 
Join Date: Feb 2010
Location: Armenia
Posts: 41
Thanks: 17
Thanked 0 Times in 0 Posts
narek has a little shameless behaviour in the past
SB65 I found a solution to my problem
Quote:
$("#draggable").draggable({revert:true});
However thank you very much!!!
narek is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:13 AM.


Advertisement
Log in to turn off these ads.