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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:51:57+00:00 2026-06-18T09:51:57+00:00

I’m looking for feedback on my coding technique for designing an interface with Javascript/SVG.

  • 0

I’m looking for feedback on my coding technique for designing an interface with Javascript/SVG. I am new to these languages, as I have recently abandoned my specialization in Adobe Flex.

The software will be a generic interface to map source signals to destination signals. Connections are represented by a grid, with rows/columns representing source/destination signals:

X X X X | destination A
X O X X | destination B
X X X X | destination C
X X X X | destination D
---------
1 2 3 4

In this -beautiful- diagram, the “0” represents source ‘signal 2’ is mapped to ‘destination B’.

I am concerned with binding the data (connection objects) to the view (SVG elements). Here’s how I did it:

the data is stored in a 2D array: connections[nSources][mDestinations]

In the view, for each item in the 2D array of connections, I create an SVG element with its ID as “celln,m” (“n,m” corresponds to its row/col indices) and add it to the DOM. I found this to be a very simple way to access any SVG element, by using document.getElementById(…), or to find the row/col a user clicked on by parsing the ‘evt.target.id’ string.

First implementation works well. But I am concerned because the interface needs to support dealing with dynamic data… sources/destination signals will be added or removed on the fly. Rows and columns can be re-arranged by the user. And it will need to support grouping signals into expandable and collapsable nodes.

A simple example: if a new row is added at index 0, I would need to update the IDs of every SVG element to increase its row by 1.

My specific question: is it ok (good practice, safe, and reliable) to be manipulating the IDs of DOM elements this much??

To see a sample of code (the functions that manipulate the IDs of the SVG elements), please see here: sample

It just seems scary that in a grid of 200×200 (for example), adding a row at index 0 means changing the IDs of 40,000 SVG elements. Does anyone see a problem with that?

  • 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-18T09:51:58+00:00Added an answer on June 18, 2026 at 9:51 am

    Anyway, you will use DOM manipulations to achieve your goals. Suggestion: use MVC pattern. Whenever user adds/deletes row, or rearrange them you modify not DOM, but the model. Then you call some listener/callback that redraws SVG. Personally I would detach the whole table (I would keep all rows in one parent <g>, for example) from DOM (with remove operation, or smth like it. What library do you use?). Then, I’ll recreate it in memory, and only after that I’ll attach (appendChild to that group) it back. This approach seems to be simple and fast enough.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

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.