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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:31:13+00:00 2026-06-10T21:31:13+00:00

I forked a JSfiddle from this blog post (just for fun on a Tuesday

  • 0

I forked a JSfiddle from this blog post (just for fun on a Tuesday evening…)
http://boundary.com/blog/2012/07/03/building-node-diagrams-in-html5/

And have been trying to create a linked new Node() every time I double click one. My fiddle is here
http://jsfiddle.net/joevallender/cGzCe/4/

I was trying not to mess with the library at first, but the fiddle includes (in resources) an altered version where I added support for the dblclick event.

Anyway, to the point! I’m passing in a function to be run on the event, and it does work in when double clicking on firstNode but I’d need to keep re-adding the event to each new created node / reference the create function somehow which would guess us into a loop.

var create = function() {
  var node = new Node({
    title: 'Node',
    stage: stage,
    w: NODE_DIMENSIONS.w,
    h: NODE_DIMENSIONS.h,
    x: 100,
    y: 100
  }).attach();
  new Segment({
    h: 5,
    stage: stage,
    origin: this,
    destination: node
  }).attach();
}
var firstNode = new Node({
    title: 'Node',
    stage: stage,
    w: NODE_DIMENSIONS.w,
    h: NODE_DIMENSIONS.h,
    x: 350,
    y: 50,
    events: {
        dblclick: create
    }
}).attach();

I feel like I should be looking to modify the prototype function for the double click event but just got a bit lost. Does anyone a) know what I’m talking about? and b) can you help. It’s not client work or anything, but I’d just like to know!

I’ve had a quick scan for duplicated, but as you might tell from my badly worded question title, I’m not entirely sure how to phrase my search!

  • 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-10T21:31:14+00:00Added an answer on June 10, 2026 at 9:31 pm

    The quickest way to accomplish this would be to add the dblclick event to the created node. You should be able to extend the Node class to do this automatically, but I’m not sure it’s necessary.

    var create = function() {
    
      var node = new Node({
        title: 'Node',
        stage: stage,
        w: NODE_DIMENSIONS.w,
        h: NODE_DIMENSIONS.h,
        x: 100,
        y: 100,
        events:{ // add the event to the created node. 
          dblclick: create
        }
      }).attach();
    
      new Segment({
        h: 5,
        stage: stage,
        origin: this,
        destination: node
      }).attach();
    
      //nodes.push(node);
    }
    

    for positioning the newly created nodes, I would suggest that it be relative to the node they are spawned from:

    var create = function() {
      var ancestor = $(event.target); // get the element that was double clicked
      var top = ancestor.position().top;  // and its position
      var left = ancestor.position().left;
    
      var node = new Node({
        title: 'Node',
        stage: stage,
        w: NODE_DIMENSIONS.w,
        h: NODE_DIMENSIONS.h,
        x: left + 100,        //new position relative to the parent.
        y: top + 100,
        events:{
          dblclick: create
        }
      }).attach();
    
      new Segment({
        h: 5,
        stage: stage,
        origin: this,
        destination: node
      }).attach();
    
      //nodes.push(node);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In this JSFiddle http://jsfiddle.net/littlesandra88/mzPxN/ am I trying to use the tablesorter plugin to sort
I forked rails and then this is what I did. > git clone git@github.com:nadal/rails.git
Please take a look to this simple jsfiddle: http://jsfiddle.net/perikut/9qUVW/2/ (sorry if using Firefox, I
So I've been working with this example: http://jqueryui.com/demos/draggable/#sortable and I've accomplished it on my
I've forked a Mercurial repository, and now I want to pull the changes from
This is a forked problem off of this question: flac: "ERROR: input file has
Running this program is printing forked! 7 times. Can someone explain how forked! is
It's a bit of a soap opera but apparently FluxBB forked from PunBB after
Is it possible to unfork (making master the forked one) heoroku database. Just perform
I'm looking for a way to recover pull requests from a forked repository. Is

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.