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 9127803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:22:07+00:00 2026-06-17T07:22:07+00:00

I have been working with arbor.js and need help with the couple of problems.

  • 0

I have been working with arbor.js and need help with the couple of problems.
I was able to create a graph based on a database, a basic graph. Now, what I need to do, click on the node and get the node data and get it displayed on the side. Also have a directed edge. So, the problems are

  1. My mousedown function is not working. Either it totally won’t work or if it works, when I click a node it automatically goes to drag, i.e it gets attatched to the mouse and I can’t release it. What am trying to do is when I click the node I need to display the node details on the side. The noded details are on another page which can be retrieved as json. My mouse handling code is as follows

    initMouseHandling:function(){
    // no-nonsense drag and drop (thanks springy.js)
    var dragged = null;
    
    // set up a handler object that will initially listen for mousedowns then
    // for moves and mouseups while dragging
    var handler = {
      clicked:function(e){
        var pos = $(canvas).offset();
        _mouseP = arbor.Point(e.pageX-pos.left, e.pageY-pos.top)
        dragged = particleSystem.nearest(_mouseP);
    
        var d = document.getElementById("infoDiv");
    
        if (dragged && dragged.node !== null){
          // while we're dragging, don't let physics move the node
          dragged.node.fixed = true
        }
        ///document.getElementById('detailBox').innerHTML=selected.node.name;
    
        $(canvas).bind('mousemove', handler.dragged)
        $(window).bind('mouseup', handler.dropped)
        $(canvas).bind('mousedown', handler.clicked)    
    
        return false
      },
      dragged:function(e){
        var pos = $(canvas).offset();
        var s = arbor.Point(e.pageX-pos.left, e.pageY-pos.top)
    
        if (dragged && dragged.node !== null){
          var p = particleSystem.fromScreen(s)
          dragged.node.p = p
        }
    
        return false
      },
    
      dropped:function(e){
        if (dragged===null || dragged.node===undefined) return
        if (dragged.node !== null) dragged.node.fixed = false
        dragged.node.tempMass = 1000
        dragged = null
        $(canvas).unbind('mousemove', handler.dragged)
        $(window).unbind('mouseup', handler.dropped)
        _mouseP = null
        return false
      }
    
      clicked:function(e){
        var pos = $(this).offset();
        var p = {x:e.pageX-pos.left, y:e.pageY-pos.top}
        selected = nearest = dragged = particleSystem.nearest(p);
        var nodeAddress = "http://localhost:7474/db/data/node/" + selected.node.name;
    
        if (selected.node !== null){
        // dragged.node.tempMass = 10000
            dragged.node.fixed = false;
            //$(canvas).unbind('mousemove', handler.dragged)        
        }
        //document.getElementById('detailBox').innerHTML=selected.node.name;
        getData(nodeAddress);
        //alert(nodeData.self);
        return false;
    
      }
    }
    
    //My click function
    //$(canvas).mousedown(function(e){
    
    //});
    

    },

    }

The above code does not work at all, I am new to jQuery as well, hence I can’t figure out the error, what the last function clicked, is trying to do is that on the clicking of a node, fetch its details from another page and display it. The function here is utter fail.
Before I tried like this,

   //My click function
    $(canvas).mousedown(function(e){
        var pos = $(this).offset();
        var p = {x:e.pageX-pos.left, y:e.pageY-pos.top}
        selected = nearest = dragged = particleSystem.nearest(p);
        var nodeAddress = "http://localhost:7474/db/data/node/" + selected.node.name;

        if (selected.node !== null){
        // dragged.node.tempMass = 10000
            dragged.node.fixed = false;
            //$(canvas).unbind('mousemove', handler.dragged)        
        }
        //document.getElementById('detailBox').innerHTML=selected.node.name;
        getData(nodeAddress);
        //alert(nodeData.self);
        return false;
    });



    // start listening
    $(canvas).mousedown(handler.clicked);

This comes outside the handler variable, with this the javascript worked fine, and it displayed the node number on the side. But I was not able to query and get the json. The graph got stuck to the pointed too.

Is this the way to try it? How can I get it done otherwise. Sorry for the big question, and the unintentional wrong format, it is my first post here.

Thanks.

  • 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-06-17T07:22:08+00:00Added an answer on June 17, 2026 at 7:22 am

    The following code for my handler works for me. YMMV.

    Instead of having a clicked function, I have a down which maps to a dropped and dragged.
    I also included a move variable which is used in the dropped function to indicate whether the node was actually clicked or just dragged.

    Hopefully this helps!

    initMouseHandling:function(){
    // no-nonsense drag and drop (thanks springy.js)
    selected = null;
    nearest = null;
    var dragged = null;
    var move = false;
    
    // set up a handler object that will initially listen for mousedowns then
    // for moves and mouseups while dragging
    var handler = {
      moved:function(e){
        var pos = $(canvas).offset();
        _mouseP = arbor.Point(e.pageX-pos.left, e.pageY-pos.top);
        nearest = particleSystem.nearest(_mouseP);
    
        if(!nearest.node){
            return false;
        }
    
        selected = (nearest.distance < nearest.node.data.radius) ? nearest : null
    
        // code for node that mouse is hovered on ('selected')
    
      },
      down:function(e){
        var pos = $(canvas).offset();
        _mouseP = arbor.Point(e.pageX-pos.left, e.pageY-pos.top)
        nearest = dragged = particleSystem.nearest(_mouseP);
        move = false;
    
        if (dragged && dragged.node !== null){
            dragged.node.fixed = true
        }
    
        $(canvas).bind('mousemove', handler.dragged)
        $(window).bind('mouseup', handler.dropped)
    
        return false
      },
      dragged:function(e){
        var old_nearest = nearest && nearest.node._id
        var pos = $(canvas).offset();
        var s = arbor.Point(e.pageX-pos.left, e.pageY-pos.top)
        move = true;
    
        if (!nearest) return
        if (dragged !== null && dragged.node !== null){
          var p = particleSystem.fromScreen(s)
          dragged.node.p = p
        }
    
        return false
      },
    
      dropped:function(e){
        var edit = $("#edit").prop('checked')
        if (dragged===null || dragged.node===undefined) return
        if (dragged.node !== null) {
            if(move===false) {
    
                // code for clicked node (dragged.node)
    
            }
            dragged.node.fixed = false
        }
        dragged.node.tempMass = 1000
        dragged = null
        selected = null
        $(canvas).unbind('mousemove', handler.dragged)
        $(window).unbind('mouseup', handler.dropped)
        _mouseP = null
        return false
      }
    }
    
    $(canvas).mousedown(handler.down);
    $(canvas).mousemove(handler.moved);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working with ASP.NET MVC for a couple of months now and
I have been working on an app for a couple of months now, but
Have been working on this question for a couple hours and have come close
I have been working with Zend for a few months now and am at
Have been working on a Tower Defense game for iOS for some time now.
I have been working a year now as a software developer for a at
I have been working with NSMutableArray and have had no problems retrieving an object
I have been working on a project that requires a bar graph to be
I have been working with a 3rd party java based REST webservice, that returns
I have been working with AndEngine and developing a game. I have now moved

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.