Using setAttribute with an array of Raphael paths

梦想的初衷 提交于 2019-12-12 04:06:12

问题


When 'things' in the following code is an array of paths...

things.square = [ RM.path("m 154.21525,71.431259 74.32805,0 0,70.496711 -74.32805,0 0,-70.496711 z").attr(attr),
                  RM.path("m 271.25132,77.933263 58.07304,0 0,56.409037 -58.07304,0 0,-56.409037 z").attr(attr2)   ];

...then this code does not work:

    things.square[1].node.setAttribute("id","clicker");

ie it fails to assign the second path in the array to id 'clicker'. However, when 'things' is just a single path...

things.square = RM.path("m 154.21525,71.431259 74.32805,0 0,70.496711 -74.32805,0 0,-70.496711 z").attr(attr);

...then it works fine:

things.square.node.setAttribute("id","clicker");

Why is this? And how can I get the first array of paths case to work? Thanks!


回答1:


I don't quite understand the purpose of the code but I would check if attr2 is valid - that's the only significant thing that the two paths differ in.
Also posting the error message and what objects are null when the exception occurs would be nice.



来源:https://stackoverflow.com/questions/3817310/using-setattribute-with-an-array-of-raphael-paths

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!