dojo : 기본값을 가진 상속 - Mixin은 발생하지 않습니다.
-
21-08-2019 - |
문제
기존 DOJO 클래스에서 새로운 DOJO 클래스 상속을 선언하고 싶지만 클래스 속성에 대한 기본값을 선택합니다. (사용자는 여전히 해당 값을 무시할 수 있습니다.)
나는 내 자신의 버전을 선언하고있다 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});
}
}
);
나는 그러한 버전의 HTML에서 선언적으로 생성하려고 노력한다. my.FilteringSelect
:
<input type="text" id="birthplace" name="birthplace"
promptMessage="Start typing, and choose among the suggestions"
storeUrl="/query/regions"
dojoType="my.FilteringSelect" />
이것은 실제로 a를 만들 것입니다 FilteringSelect
원하는대로 promptMessage
(이는 슈퍼 클래스가 매개 변수를 올바르게 받고 있음을 의미하지만) hasDownArrow
~이다 true
(내 기본 믹스와는 반대로) 및 the store
~이다 null
(및 Firebug Console은 다음을보고합니다 storeUrl
이다 "undefined
").
내가 뭘 잘못하고 있죠?
해결책
죄송합니다! 나는 정말로 그들의 머리에 물건이 있었다. 나는 올바른 길을 찾았다. 다음 작품 :
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});
}
}
);
제휴하지 않습니다 StackOverflow