Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6229621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:36:05+00:00 2026-05-24T09:36:05+00:00

All, I’m pretty new with JavaScript and this is my first attempt with the

  • 0

All,

I’m pretty new with JavaScript and this is my first attempt with the YUI 3.0 framework. I’m trying to create something where when I drag a ‘player’ div onto a ‘slot/drop’ div and then alert pops up telling me the project number and some other attributes from the dragged div and drop target (slot/drop). I can get the alert to work for the dragged div but am having a hard time referencing the drop target div and getting it’s attributes. Could someone assist? If you need more info let me know.

The reason I need this is due to the fact that I have multiple drop targets and need to find out which particular target was dropped on.

I appreciate any help!

YUI({ filter: 'raw' }).use('dd-drop', 'dd-proxy', 'dd-constrain', 'dd-ddm-drop', function(Y) {

var slots = Y.one('#workarea').all('.slot');
Y.each(slots, function(v, k) {
    var id = v.get('id'), groups = ['two'];
    switch (id) {
        case 't1':
        case 't2':
            groups = ['one'];
            break;
    }
    var drop = new Y.DD.Drop({
        node: v,
        groups: groups
    });
});

var players = Y.one('#workarea').all('.player');
Y.each(players, function(v, k) {
    var id = v.get('id'), groups = ['one', 'two'];
    switch (id) {
        case 'pt1':
        case 'pt2':
            groups = ['one'];
            break;
        case 'pb1':
        case 'pb2':
            groups = ['two'];
            break;
    }
    var drag = new Y.DD.Drag({
        node: v,
        groups: groups,
        dragMode: 'intersect'
    }).plug(Y.Plugin.DDProxy, {
        moveOnEnd: false
    }).plug(Y.Plugin.DDConstrained, {
        constrain2node: '#workarea'
    });
    drag.on('drag:start', function() {
        var p = this.get('dragNode'),
            n = this.get('node');
            n.setStyle('opacity', .25);
            if (!this._playerStart) {
                this._playerStart = this.nodeXY;
            }
        p.set('innerHTML', n.get('innerHTML'));
        p.setStyles({
            backgroundColor: n.getStyle('backgroundColor'),
            color: n.getStyle('color'),
            opacity: .65
        });
    });
    drag.on('drag:end', function() {
    var n = this.get('node');
    n.setStyle('opacity', '1');
    var project_number = n.getAttribute('project_number');
            var div_number= n.getAttribute('div_number');
            alert ( "! " + project_number + " ! " + track_number + " ! ");
    self.location='project.php?project=' + project + '&div_id=' + div_number; [/code]

    });


    drag.on('drag:drophit', function(e) {
        var xy = e.drop.get('node').getXY();
        this.get('node').setXY(xy);


    });
    drag.on('drag:dropmiss', function(e) {
        if (this._playerStart) {
            this.get('node').setXY(this._playerStart);
            this._playerStart = null;
        }
    });
});


});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:36:06+00:00Added an answer on May 24, 2026 at 9:36 am

    In the drag.on drag:drophit method add this:

    var target = e.drop.get('node');
    

    So now it would look like:

    drag.on('drag:drophit', function(e) {
        var xy = e.drop.get('node').getXY();
        this.get('node').setXY(xy);
    
        var target = e.drop.get('node');
    });
    

    If you alert(target._node.id) (within the scope of that method) you’ll have the id of the drop target.

    To take a closer look at the target object use console and spit it out like so:

    console.log(target);
    

    You’ll need to be using Chrome, or have the FireBug AddOn installed for console.log to work. Without you’ll crash the javascript rendering.

    You should be able to add that snippet into any of the drag.on methods.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All the info I've found on the internet about this says to use something
All I am trying to create an app that start capturing the video from
All I want is to update an ListViewItem's text whithout seeing any flickering. This
All the talk on WP7 resolution = 800x480. I can create more than 480
All math functions in JavaScript use radians in place of degrees. Yet they are
All this might look too trivial but read it through - I have simple
All I did was I added a single more argument (iterations) to this function:
All of the sudden all of the calls to my web services get this
all, I am trying to multiply a matrix to a vector in OpenGL, but
All, I'm trying to split my MSTest test run into multiple runs because I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.