[Dojo-interest] dijit.layout.StackContainer Programatically

Daniel daniel.carrera at zmsl.com
Tue Dec 11 17:59:08 UTC 2007


Dustin Machi wrote:
>>>> ... = new dijit.layout.StackContainer(dojo.byId('myNewDiv'));
>>>> ... = new dijit.layout.StackContainer(params, dojo.byId('myNewDiv'));
>>>> ... = new dijit.layout.StackContainer({
>>>> 	dara: ... , obj: dojo.byId('myNewDiv')
>>>> });
...
> Well I don't think the last one is valid, but there aren't really that
> many different posibilities here
...

> It may appear that you can do things in a number of different ways, and
> there are a few minor different variations as mentioned.  The main thing
> is that there are a number of ways it can _look_ because you could of
> course replaces things with object literals or whatever. For example:
> 
> var blah = new Widget({
> 	blah: "foo",
> 	bar: "foobar"
> });
> 
> is not different (necessarily) from
> 
> var blah = new Widget(params);


Well, I know _that_, but the examples I gave all have different signatures:

var = new Widget(dojo.byId('myNewDiv'));
var = new Widget(params, dojo.byId('myNewDiv'));
var = new Widget({
     dara: ... , obj: dojo.byId('myNewDiv')
});

Different signatures. The first one takes a Dom object. The second takes 
two parameters, an object and a Dom object. The third one takes one 
parameter, an object.

>>> They are referencing two different things.  dijit's don't have to have  
>>> dom references.  Dom references don't have to have Dijit references.
>> Dijits don't have to have dom references? Really? Could you explain that 
>> point?
>>
>> I understand that not all Dom references have a Dijit reference, but the 
>> opposite confuses me. I thought that objects with Dijit references would 
>> be a subset of those with Dom references.
> 
> dojo.byId() returns a domNode given an id.  It is equivalent to
> document.getElementsById()
> 
> dijit.byId() returns a Widget given a widgetId. If you wanted the
> domNode reference for your widget, you would say
> dijit.byId("myWidget").domNode.

Look again at Jon's note and my subsequent question. Jon says that 
Dijits don't have to have a Dom reference. I asked "really?". Your 
example shows a dijit *with* a Dom reference. Can you show me a dijit 
*without* a Dom reference?

> Personally I never do just the "foo" and was unaware that you could
> "drop" the first parameter.

 From Peter's email, it looks like that might have been a typo on Jon's 
part, and that you actually cannot drop the first parameter.

> One thing to remember that I didnt' see
> mentioned here is that if you have it create the domNode automatically,
> it does not add it to the document, it is your responsibility to do so.
>   Something like:
> 
> var w = new Widget();
> dojo.body().appendChild(w.domNode);

Would 'w', before being appended, be an example of a dijit that does not 
have a Dom reference? (re: my question a few paragraphs above).

I'm still thinking about dojo.byId vs dijit.byId. Consider this example:

var w1 = new Widget();
w1.id  = "myId";  // How *do* you give a dijit object an id?
var w2 = dijit.byId("myId");

Notice: The widget 'w1' has not been appended to anything, so it is not 
yet on the Dom. Therefore, you cannot run dojo.byId("myId"). But *can* 
you run dijit.byId("myId")?


This is potentially an example of a case where you can run dijit.byId 
but you cannot run dojo.byId, which would possibly justify the 
distinction between the two functions.


> Sure.  But don't for get that there are alot of pages to review, busy
> people, and unlike most commercial or private documentation, the review
> of our documentation happens in public as things progress.


To be clear, 99% of my documentation experience is in public processes. 
I have only participated in one commercial book. So, when I make 
suggestions, I'm not speaking from a private "keep things hidden" point 
of view.

The thing is, there isn't much of a review process right now. All you 
can really do is add Drupal comments, which limits the sort of reviews 
you can get.

Daniel.


More information about the Dojo-interest mailing list