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 02-25-2013, 12:54 PM   PM User | #1
Moribundus
New to the CF scene

 
Join Date: Feb 2013
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Moribundus is an unknown quantity at this point
Drag and drop - Drop in different Boxes

Hey There,

I´m German and new, so sry for my english.

I used a jquery ui multi Drag and Drop Solution on my local website here is the code:

Code:
$(window).load(function(){
	var selectedObjs;
	var draggableOptions = {
		start: function(event, ui) {
			//get all selected...
			if (ui.helper.hasClass('selected')) selectedObjs = $('div.selected');
			else {
				selectedObjs = $(ui.helper);
				$('div.selected').removeClass('selected')
			}
			
		},
		drag: function(event, ui) {
			var currentLoc = $(this).position();
			var prevLoc = $(this).data('prevLoc');
			if (!prevLoc) {
				prevLoc = ui.originalPosition;
			}

			var offsetLeft = currentLoc.left-prevLoc.left;
			var offsetTop = currentLoc.top-prevLoc.top;
			
			moveSelected(offsetLeft, offsetTop);
			$(this).data('prevLoc', currentLoc);
			globalElement = $(this);
		}
	};
	
	$('.activity').draggable(draggableOptions).click(function(){$(this).toggleClass('selected')});

$('.planning').droppable({
  drop: function(event, ui) {
    selectedObjs.appendTo(this);
  }
});


	function moveSelected(ol, ot){
		console.log("moving to: " + ol + ":" + ot);
		selectedObjs.each(function(){
			$this =$(this);
			var p = $this.position();
			var l = p.left;
			var t = p.top;
			console.log({id: $this.attr('id'), l: l, t: t});


			$this.css('left', l+ol);
			$this.css('top', t+ot);
			
		})
	}
});
and html:
Code:
<table class="planningtable">
	<tr>
		<td class="planning"></td>
		<td class="planning"></td>
		<td class="planning"></td>
		<td class="planning"></td>
		<td class="planning"></td>
		<td class="planning"></td>
		<td class="planning"></td>
		<td class="planning"></td>
		<td class="planning"></td>
		<td class="planning"></td>
	</tr>
	<tr>
		<td class="planning"></td>
		<td class="planning"></td>
		<td class="planning"></td>
		<td class="planning"></td>
		<td class="planning"></td>
		<td class="planning"></td>
		<td class="planning"></td>
		<td class="planning"></td>
		<td class="planning"></td>
		<td class="planning"></td>
		<td class="planning"></td>
	</tr>
</table>

<table class="legend">
	<tr>
		<td>
			<div id="drag1" onkeydown="deldiv()" class="activity" >FO</div><br>
			<div id="drag2" onkeydown="deldiv()" class="activity" >FO</div><br>
			<div id="drag3" onkeydown="deldiv()" class="activity" >FO</div><br>
		</td>
	</tr>
</table>
This Solution can drag and drop more than one div´s but only the div that i touched dropped.
I try to find a solution that the div´s can´t only dropped together, i need a solution that the div´s can drop in different boxes together.

But i´m not a pro in JS and need help, pls.

i make a picture for what i want:



I hope anyone can Understand and help me.

Kind Regards

Last edited by Moribundus; 02-25-2013 at 01:53 PM..
Moribundus is offline   Reply With Quote
Old 02-26-2013, 07:32 AM   PM User | #2
Moribundus
New to the CF scene

 
Join Date: Feb 2013
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Moribundus is an unknown quantity at this point
Drag and drop - Drop in different Boxes

Why is my Post empty?
Moribundus is offline   Reply With Quote
Old 02-26-2013, 08:35 AM   PM User | #3
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,583
Thanks: 5
Thanked 864 Times in 841 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Your post was in der moderation queue, probably because you modified it later on. The spam protection is a little nervous sometimes.
__________________
Don’t click this link!
VIPStephan is online now   Reply With Quote
Users who have thanked VIPStephan for this post:
Moribundus (02-26-2013)
Old 02-26-2013, 01:43 PM   PM User | #4
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by VIPStephan View Post
Your post was in der moderation queue, probably because you modified it later on. The spam protection is a little nervous sometimes.
Donner und Blitzen! The German for "moderation queue" is feminine so die not der.

die Mäßigungswarteschlange
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is online now   Reply With Quote
Old 02-26-2013, 11:27 PM   PM User | #5
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,583
Thanks: 5
Thanked 864 Times in 841 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Yes, you are right in that it is feminine but you failed to see that “moderation queue” here is in dative case. So, the plain noun is in fact “die Mäßigungswarteschlange” (although that isn’t actually a real word anyway; “Moderation” is used in German, too, and Germans would probably say “Moderationswarteschlange” (which is still feminine)) but here I indicate that something is in the “moderation queue” which in German becomes “in der Mäßigungswarteschlange”. If it was masculine you would say “in dem Mäßigungswarteschlange”, or actually short “im Mäßigungswarteschlange”), even though the plain noun would be “der …”.

But forgive my negligence, I will do my best to write proper English.
__________________
Don’t click this link!
VIPStephan is online now   Reply With Quote
Reply

Bookmarks

Tags
drag, drop, javascript, jquery ui

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 07:18 PM.


Advertisement
Log in to turn off these ads.