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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:30:14+00:00 2026-06-04T10:30:14+00:00

Here is a working jsFiddle example. Basically you enter a number and hit Add.

  • 0

Here is a working jsFiddle example.

Basically you enter a number and hit “Add”. A row containing that number of boxes will be generated using Raphael and the viewbox will resize to fit the rows. Add more rows and the viewbox will resize again. This works fine.

My issue is that after I create the boxes, I add a delete object at the end of the row. Clicking this should simply remove the row. This looks like it works fine, except that once I remove a row trying to add a new one will result in the viewbox shrinking with the console message

Unexpected value 10 0 NaN NaN parsing viewBox attribute.

I know the error is coming from the following two lines of code:

var sectionSize = section.getBBox();
paper.setViewBox(sectionSize.x, sectionSize.y, sectionSize.width, sectionSize.height, true);

where sectionSize.width and .height are NaN, but I don’t know why. Am I not removing the row correctly?

Complete code:

$(window).load(function() {

    var paper = Raphael("container", 600, 500);
    var section = paper.set();
    var rowCount = 0;
    var boxSize = 15;
    var boxPadding = 5;
    var pathString = " m0,0 h" + boxSize + ", v" + boxSize + " h-" + boxSize + " v-" + boxSize + " z";

    $("#add-row").click(function() {
        var row = paper.set();

        for (var i = 0; i < $("#count").val(); i++) {
            var x = ((boxSize + boxPadding) * i) + (boxPadding * 2);
            var y = ((boxSize + boxPadding) * rowCount);

            var transformString = "t" + x + "," + y + ", s1,1,0,0 r0,0,0";

            var box = paper.path(pathString).transform(transformString);
            box.attr({
                fill: "red",
                stroke: "black",
                cursor: "pointer"
            });
            row.push(box);

            if (i == $("#count").val() - 1) {
                var del = paper.text(((box.getBBox().width + x) + boxPadding), ((box.getBBox().height / 2) + y), "x");
                del.click(function() {
                    row.remove();
                });

                row.push(del);
            }
        }

        rowCount++;
        section.push(row);

        // Resize ViewBox
        var sectionSize = section.getBBox();
        paper.setViewBox(sectionSize.x, sectionSize.y, sectionSize.width, sectionSize.height, true);

    });
});

HTML

<input type="text" id="count" value="3" />
<button id="add-row">Add</button>

<div id="container" style="border: 1px solid black;">
</div>
  • 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-04T10:30:16+00:00Added an answer on June 4, 2026 at 10:30 am

    Apparently I wasn’t removing the element properly. I had to remove it from the section set before I removed the element itself, otherwise any call to getBBox would result in the width and height being NaN.

    del.click(function() {
      section.splice($.inArray(row, section), 1);
      row.remove();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This example working great because here containment is body http://jsfiddle.net/roXon/hMmbK/2/ when i use container
I'm working on a jquery carousel. You can see the example here: http://jsfiddle.net/6fwbS/2/ Click
i have a problem with the revert speed. Here is a working example http://www.jsfiddle.net/V9Euk/94/
Here is a working example: http://jsfiddle.net/FzZwt/8/ If I pass false to the toggle() first
Here is my working example on jsfiddle, its working on almost every browser (i
http://jsfiddle.net/danesoul/tSCus/2/ - Here is working example of simple JQuery UI Tabs interface. Commented string
here is the working fiddle: http://jsfiddle.net/2bNsC/67/ I need to place the 3 items (text
Here's the code I'm currently working with: http://jsfiddle.net/gEMCm/ I'm trying to make an image
I'm working a but of code that is supposed to add a tooltip that
Here's the fiddle I'm working with: http://jsfiddle.net/Scd9b/ How can I delay the href function

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.