[ 6 posts ]

Merlin

  • Username: Teonnyn
  • Joined: Wed Feb 24, 2010 6:53 pm
  • Posts: 5
  • Offline
  • Profile

YUI 3.x multiple Drag and Drop

Post Posted: Wed Feb 24, 2010 7:08 pm
+0-
Hello! I'm writing a card game of sorts using YUI as a basis - primarily using Drag and Drop, however my experience with Javascript is fairly limited. The PHP side is ready to go. The user's deck is shown using mySQL/PHP and laid out in a table. However, while I can create individual drag instances.... I'm lost as to how to apply multiple drag instances. Each card - and there could be up to a hundred - needs to be draggable. Any user's individual deck could be anywhere from 20 to 100 cards, so the Javascript ... script.. needs to be intelligent enough to detect that and apply the drag accordingly. There are five drop targets avaliable - these will stay the same and don't have to be dynamically defined. What is the best way to do multiple drag instances in this fashion?

The other issue here is much simpler - Once a card is dragged onto a drop target.. it needs to trigger a related PHP function (all already prepared).... can that be done? These functions don't need to reload the page/etc.

Dav Glass

  • Username: davglass
  • Joined: Thu Aug 28, 2008 9:28 am
  • Posts: 2088
  • Location: Marion, IL, US
  • Twitter: davglass
  • GitHub: davglass
  • Gists: davglass
  • IRC: davglass
  • Offline
  • Profile
Tags:

Re: YUI 3.x multiple Drag and Drop

Post Posted: Wed Feb 24, 2010 7:46 pm
+0-
The second part is easy, on drop make an IO request to your page to call the php function.

The first part is a little more complicated & I would need a page with an example.

Merlin

  • Username: Teonnyn
  • Joined: Wed Feb 24, 2010 6:53 pm
  • Posts: 5
  • Offline
  • Profile

Re: YUI 3.x multiple Drag and Drop

Post Posted: Wed Feb 24, 2010 7:50 pm
+0-
Basically I'm looking for something shown in the examples but done dynamically, with up to a hundred possible draggable objects:
http://developer.yahoo.com/yui/examples ... roups.html

I tried to do it using a class, however that just worked for a single object and ignored the others.

Dav Glass

  • Username: davglass
  • Joined: Thu Aug 28, 2008 9:28 am
  • Posts: 2088
  • Location: Marion, IL, US
  • Twitter: davglass
  • GitHub: davglass
  • Gists: davglass
  • IRC: davglass
  • Offline
  • Profile

Re: YUI 3.x multiple Drag and Drop

Post Posted: Wed Feb 24, 2010 7:56 pm
+0-
Try this:

Example

Click here to see the revision history on this Gist.

Merlin

  • Username: Teonnyn
  • Joined: Wed Feb 24, 2010 6:53 pm
  • Posts: 5
  • Offline
  • Profile

Re: YUI 3.x multiple Drag and Drop

Post Posted: Wed Feb 24, 2010 9:58 pm
+0-
Thank you! I never would've guessed it was that simple. Kept trying to do it in groups like the examples showed.. which predictably didn't work exactly!

Merlin

  • Username: Teonnyn
  • Joined: Wed Feb 24, 2010 6:53 pm
  • Posts: 5
  • Offline
  • Profile

Re: YUI 3.x multiple Drag and Drop

Post Posted: Wed Feb 24, 2010 10:53 pm
+0-
Okay, that worked. I just need to figure out how to constrain these to a certain area now... items.plug() doesn't seem to want to work
  [ 6 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum