2010-07-21 8 views
1

나는 Dojo 초보자이며 사용자 정의 템플리트 Dojo 위젯을 작성하려고 시도 중이다. attributeMap을 사용하여 사용자 정의 Dojo 위젯 속성을 HTML 텍스트 영역 요소의 텍스트 노드에 맵핑하는 올바른 방법은 무엇입니까? 커스텀 Dojo 위젯을 선언적으로 생성하는 동안 textarea의 값을 설정할 수 있기를 원합니다. 예 : ... ... 사용자 정의 Dojo 위젯에서 attributemap을 올바르게 설정하는 방법은 무엇입니까?

<script type="text/javascript"> 
    dojo.require("dijit._Widget"); 
    dojo.require("dijit._Templated"); 

    dojo.addOnLoad(function() { 
     dojo.declare("MyCustomWidget", [dijit._Widget, dijit._Templated], { 
      txtComment: "undefined", 
      templateString: "<div><textarea dojoAttachPoint="contentNode" rows='10' cols='20'></textarea></div>", 
      attributeMap: { 
       txtComment: { 
        node: "contentNode", // what should the correct mapping be to allow the 
        type: "innerHTML" // setting of txtComment declaratively above in the body? 
       }, 
      } 
     }); 
     dojo.parser.parse(); 
    }); 
</script> 

답변

1

좋은 점은 내가 여기. 나는 완전히 정확하지 않을 수도 있습니다.

<body><div dojoType="abcd.MyCustomWidget" txtComment="decl value"></div></body> 
<script type="text/javascript"> 
dojo.require("dijit._Widget"); 
dojo.require("dijit._Templated"); 
dojo.declare("MyCustomWidget", [dijit._Widget, dijit._Templated], { 
     txtComment: "undefined", 
     templateString: "<div><textarea dojoAttachPoint="contentNode" rows='10' cols='20'></textarea></div>", 
     attributeMap: { 
      txtComment: { 
       node: "contentNode", // what should the correct mapping be to allow the 
       type: "innerHTML" // setting of txtComment declaratively above in the body? 
      }, 
     } 
    }); 
dojo.addOnLoad(function() { 
    // for programatically creating widget. 
    new abcd.MyCustomWidget({txtComment:'what ever'},"adcd") 

}); 

아래 그림처럼 1) 먼저, 우리는 코드를 초래할 것이다 ("MyCustomWidget"[dijit._Widget, dijit._Templated, 선언문 dojo.addOnLoad (전) dojo.declare를 사용해야

관련 문제