javascript - Raphael JS - paper.remove - Stack Overflow

Just getting started with Raphael.Now I'm finding that paper.remove() is generating a script error

Just getting started with Raphael.

Now I'm finding that paper.remove() is generating a script error:

 "SCRIPT5009: 'removed' is undefined 

Is this a script bug?

My variable paper is initialized thus:

var paper = new Raphael(document.getElementById('canvas_container'), 500, 500);

My HTML body has:

<div id="canvas_container"></div>  

This is more info -- I am using Raphael 2.0 which I just downloaded again. Running IE9. Following is the Raphael JS function that is highlighted as the problem:

R.prototype.remove = function () {

        eve("remove", this);
        this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas);
        for (var i in this) {
            this[i] = removed(i);
        }
    };

the line ... removed(i) is highlighted --> SCRIPT5009: 'removed' is undefined

BTW I am new to this forum. Is there a way to respond to a thread other than "Answer Your Question"?

Just getting started with Raphael.

Now I'm finding that paper.remove() is generating a script error:

 "SCRIPT5009: 'removed' is undefined 

Is this a script bug?

My variable paper is initialized thus:

var paper = new Raphael(document.getElementById('canvas_container'), 500, 500);

My HTML body has:

<div id="canvas_container"></div>  

This is more info -- I am using Raphael 2.0 which I just downloaded again. Running IE9. Following is the Raphael JS function that is highlighted as the problem:

R.prototype.remove = function () {

        eve("remove", this);
        this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas);
        for (var i in this) {
            this[i] = removed(i);
        }
    };

the line ... removed(i) is highlighted --> SCRIPT5009: 'removed' is undefined

BTW I am new to this forum. Is there a way to respond to a thread other than "Answer Your Question"?

Share Improve this question edited May 14, 2014 at 12:31 Margo 6824 gold badges13 silver badges30 bronze badges asked Oct 10, 2011 at 1:33 sudoku-sansudoku-san 411 silver badge4 bronze badges 1
  • Apart from answering a question, you can only enter-in ments. – Prisoner ZERO Commented Jun 15, 2012 at 16:40
Add a ment  | 

2 Answers 2

Reset to default 4

I've run across this a couple of times. The line 4443 method as suggested by sudoko-san does work in browsers but not backwards patible with IE-7 & 8 (the whole point of using raphael).

Another work around is to implement the following code in your javascript:

try{
    paper.remove();
}
catch (error) {
    // this catches the error and allows you to proceed along nicely
}

That's it!

I don't know if you've supplied enough information to answer this question.

  • What version of Raphael are you using?
  • On what browser?
  • Is it being loaded up correctly - can you create any Raphael objects?

If all you're doing is deleting the paper, see the fiddle below.

JSFiddle

It seems to work fine for me with Raphael 1.5.2

Hope that helps (even slightly).

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745580608a4634233.html

相关推荐

  • javascript - Raphael JS - paper.remove - Stack Overflow

    Just getting started with Raphael.Now I'm finding that paper.remove() is generating a script error

    18小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信