I wish to declare a new dojo class inheriting from an existing dojo class, but with my own choice of default values for the class's properties. (The user can still override those values.)
I am declaring my own version of the dijit.form.FilteringSelect
such that:
- the
hasDownArrow
property defaults tofalse
(rather than the standardtrue
) and - there's an extra possible property
storeUrl
which allows me to connect theFilteringSelect
to the correspondingQueryReadStore
.
Here's what I did, without success:
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});
}
}
);
Say, I try to generate declaratively in the HTML such a version of my.FilteringSelect
:
<input type="text" id="birthplace" name="birthplace"
promptMessage="Start typing, and choose among the suggestions"
storeUrl="/query/regions"
dojoType="my.FilteringSelect" />
This will indeed create a FilteringSelect
with the desired promptMessage
(which means that the superclass is properly getting the params), but hasDownArrow
is true
(contrary to my default mixin) and the store
is null
(and the Firebug console reports that storeUrl
is "undefined
").
What am I doing wrong?