Reputation: 15866
var circle = paper.getById(data.Id);
console.log("circle : " + circle);
circle.attr({ opacity: data.Opacity / 100 });
console output:
circle : Raphaël’s object
and
Uncaught TypeError: Cannot call method 'attr' of null
I think, first I convert object to circle? How can I change element attribute?
Thanks...
Upvotes: 0
Views: 2788
Reputation: 13842
Its not really clear what your data object is, to know if thats correct, or if the id has been set. Here is an example.. with a fiddle here http://jsfiddle.net/Uvcy9/2/
var paper = Raphael('container',200,200);
var newCircle = paper.circle(100,20,20);
newCircle.id='circle1';
paper.add( newCircle );
/// some code here, later we want to reference it...
var circle = paper.getById('circle1');
circle.attr({ fill: 'red', opacity: circle.attr('opacity') / 10 });
Upvotes: 3