2012-10-12 3 views
2

두 번째로, 나는 raphaeljs lib를 사용하여 다른 경로에서 SVG 형식을 변환합니다.
나는 그를 raphaeljs 함수로 호출하여 경로를 얻고 싶습니다. 2.1.0 => getById (id);
그러나 Chrome이나 Firefox는 getById 함수가 없다고 알려줍니다! 왜 그런지 모르겠다 고요? function getById Raphael js

내 코드의 일부입니다 :

rsrGroups = [path_c_trsp,path_i_trsp,path_l_trsp,path_o_trsp]; 
len = rsrGroups.length; 

for(var i = 0; i < len; i++){ 
    var el = rsrGroups[i]; 

el.mouseover(function() { 
    rsrGroupsMin.forEach(function(el){ 
     var getPath = el.getById('el.id'); // here is the method called ! 
     alert(getPath); 
     el.animate({opacity: 0.5},350,function() {}); 
     rsrGroups2.forEach(function(tri){ 
      tri.animate({opacity: 0.5},350,function() {}); 
     }); 
    }); 
    this.animate({opacity: 1},350,function() {}); 
}); 
} 

그리고이 크롬에 의해 주어진 오류입니다 : 내가 다른 일을 시도

Uncaught TypeError: Object Raphaël’s object has no method 'getById'

그러나 아무도는 작동하지 않습니다 :/

답변

2

getById 요소가 아닌 종이 객체에 대한 메소드입니다. 즉,

var paper = Raphael(10, 50, 320, 200); 
paper.getById('id') 

또는 paper 변수에 액세스 할 수없는 경우 el.paper.getById를 호출 할 수 있습니다.

+0

고맙다. 내 코드를보고 나 혼자서 찾는다. ^^ var을해야한다. getPath = ** rsr **. getById (this.id); – Glou94

-1

el.getElementById('el.id')을 의미합니까?

관련 문제