2009-02-04 10 views
1

기존 dojo 클래스를 상속하는 새로운 dojo 클래스를 선언하고 클래스 속성에 대한 자체 기본값을 선택한다. (사용자는 여전히 그 값을 겹쳐 쓸 수 있습니다.)dojo : 기본값으로 상속 - mixin이 발생하지 않는다.

을 나는 내 자신의 버전을 선언하고 dijit.form.FilteringSelect 있도록 :

  • hasDownArrow 속성 기본값 false (보다는 표준 true) 및
  • 에있다 가능한 추가 속성 storeUrl을 사용하면 FilteringSelect을 해당 QueryReadStore에 연결할 수 있습니다. 여기

내가 성공하지, 무슨 짓을했는지 :

dojo.provide("my.FilteringSelect"); 
dojo.require("dijit.form.FilteringSelect"); 
dojo.require("dojox.data.QueryReadStore"); 
dojo.declare(
    "my.FilteringSelect", 
    [ 
     dijit.form.FilteringSelect, /* base superclass */ 
     { hasDownArrow:false, storeUrl:"/" } /* mixin */ 
    ], 
    { 
     constructor: function(params, srcNodeRef){ 
     console.debug("Constructing my.FilteringSelect with storeUrl " 
         + this.storeUrl); 
     this.store = new dojox.data.QueryReadStore({url:this.storeUrl}); 
     } 
    } 
); 

말, 나는 my.FilteringSelect의 HTML 같은 버전에서 선언적으로 생성하려고 :

<input type="text" id="birthplace" name="birthplace" 
     promptMessage="Start typing, and choose among the suggestions" 
     storeUrl="/query/regions" 
     dojoType="my.FilteringSelect" /> 

이 참으로 FilteringSelect을 만듭니다 promptMessage (즉, 수퍼 클래스가 params를 제대로 가져 오는 것을 의미 함), hasDownArrowtrue (내 기본 설정 mi와는 반대로 xin)이고 storenull입니다 (방화 광 콘솔은 storeUrl이 "undefined"이라고보고합니다).

내가 뭘 잘못하고 있니?

답변

1

죄송합니다. 나는 정말 머리가 아팠다. 나는 올바른 방법을 찾았습니다. 다음 작품들 :

dojo.provide("my.FilteringSelect"); 
dojo.require("dijit.form.FilteringSelect"); 
dojo.require("dojox.data.QueryReadStore"); 
dojo.declare(
    "my.FilteringSelect", 
    dijit.form.FilteringSelect, 
    { 
     hasDownArrow : false, 
     storeUrl : "/", 
     constructor: function(params, srcNodeRef){ 
     dojo.mixin(this, params); 
     console.debug("Constructing my.FilteringSelect with storeUrl " 
         + this.storeUrl); 
     this.store = new dojox.data.QueryReadStore({url:this.storeUrl}); 
     } 
    } 
);