Opened 12 years ago

Closed 12 years ago

#3406 closed defect (fixed)

Dynamically loaded content in ContentPane doesn't resize itself onload and on window resize

Reported by: guest Owned by: bill
Priority: high Milestone: 1.0
Component: Dijit Version: 0.9
Keywords: Cc:
Blocked By: Blocking:

Description

today i submit the ticket #3042

But the bug i submit is a general problem of parsing on the content loaded async by ContentPane?! I fix the problem with SplitContainer? for now.

Here is my fix if you want: in SplitContainer?.js in "startup" function add on the last row of the function: this.resize();

in dojo parser.js change in "instantiate" function:

dojo.forEach(thelist, function(widget){
			if(widget && widget.startup && (!widget.getParent || widget.getParent()==null )){
        widget.startup();
			}
		}

with this:

dojo.forEach(thelist, function(widget){
			if(widget && widget.startup && (!widget.getParent || widget.getParent()==null || 
                                      (widget.getParent && widget.getParent()!=null && widget.getParent()._started) )){
        var linkResize=false;
        if((widget.getParent && widget.getParent()!=null && widget.getParent()._started) && 
            widget.getParent().resize && widget.resize)
          linkResize=true;
          
				widget.startup();
				if(linkResize){
          dojo.connect(widget.getParent(),"resize",widget,"resize");
        }
			}
		}

Change History (10)

comment:1 Changed 12 years ago by bill

Milestone: 0.9beta1.0
Priority: highnormal
severity: criticalnormal
Summary: Dinamically loaded content in ContentPane doesn't resize itself onload and on window resizeDynamically loaded content in ContentPane doesn't resize itself onload and on window resize

There are two categories of layout widgets on a page:

  • top level
  • children of other layout widgets

When the parser calls SplitContainer?.startup(), this code is executed:

// If I am a top level widget
if(!this.getParent || !this.getParent()){
	// Do recursive sizing and layout of all my descendants
	this.resize();

Since the SplitContainer?'s parent is a ContentPane?, which isn't a layout widget, the SplitContainer? is supposed to be considered "top level".

I guess the condition is incorrect. It should probably check if getParent().isLayoutContainer is set.

comment:2 Changed 12 years ago by guest

Yes, but the parser doesn't call the startup because in this case SplitContainer? isn't a Top level widget. This is the problem... I add this condition: (widget.getParent && widget.getParent()!=null && widget.getParent()._started) "if my parent is started (but i'm not) then start me with startup()"

and

{{{if(getParent().isLayoutContainer()){

Do recursive sizing and layout of all my descendants this.resize();}}}

work only for the first time! Because when i resize the window, ContentPane? doesn't resize the SplitContainer? "dinamic" child.. This is because I add this:

dojo.connect(widget.getParent(),"resize",widget,"resize");

comment:3 Changed 12 years ago by bill

Parser calls startup() on every widget.

comment:4 in reply to:  3 Changed 12 years ago by guest

Replying to bill:

Parser calls startup() on every widget.

It isn't true!!

Line 164 dojo parser.js

if(widget && widget.startup && (!widget.getParent || widget.getParent()==null))
  widget.startup();

if NOT !widget.getParent || widget.getParent()==null it doesn't call startup!!

comment:5 Changed 12 years ago by bill

Ah I see, sorry about that. OK, something needs to be changed. Maybe SplitContainer?.getParent() should return null since the ContentPane? doesn't really do parental duties. Have to think about the exact conditions.

comment:6 in reply to:  5 ; Changed 12 years ago by guest

Replying to bill:

Ah I see, sorry about that. OK, something needs to be changed. Maybe SplitContainer?.getParent() should return null since the ContentPane? doesn't really do parental duties. Have to think about the exact conditions.

Maybe. But it could be a problem if we want to get the parent in other cases. I think that my condition in the parser (like first "post"):

(widget.getParent && widget.getParent()!=null && widget.getParent()._started)

is the best solution "for now" to catch the problem and startup the widget and in that case link the resize event if widget and its parent are Sizable.

Thank you for your attention.

PS: i'm italian, sorry for my bad english

comment:7 in reply to:  6 Changed 12 years ago by guest

Replying to guest:

Replying to bill:

Ah I see, sorry about that. OK, something needs to be changed. Maybe SplitContainer?.getParent() should return null since the ContentPane? doesn't really do parental duties. Have to think about the exact conditions.

Maybe. But it could be a problem if we want to get the parent in other cases. I think that my condition in the parser (like first "post"):

(widget.getParent && widget.getParent()!=null && widget.getParent()._started)

is the best solution "for now" to catch the problem and startup the widget and in that case link the resize event if widget and its parent are Sizable.

Thank you for your attention.

PS: i'm italian, sorry for my bad english

connecting resize parent with resize widget cause problem.. i'm trying to find a solution..

comment:8 Changed 12 years ago by guest

I work all day, but this is the solution!!! Yeah!!

add to ContentPane?.js:

resize:function(){
		  for(var i=0;i<this.getChildren().length;i++){
		    var ch=this.getChildren()[i];
        if(ch.resize)
          dijit.base.Layout.prototype.resize.apply(ch, arguments);
      }
      dijit.base.Layout.prototype.resize.apply(this, arguments);
    }

and in parser.js change this:

dojo.forEach(thelist, function(widget){
			if(widget && widget.startup && (!widget.getParent || widget.getParent()==null )){
        widget.startup();
			}
		});

with this:

dojo.forEach(thelist, function(widget){
			if(widget && widget.startup && (!widget.getParent || widget.getParent()==null || 
                                      (widget.getParent && widget.getParent()!=null && widget.getParent()._started) )){
				widget.startup();
				
				if((widget.getParent && widget.getParent()!=null && widget.getParent()._started) && widget.resize)
            widget.resize();
			}
		});

comment:9 Changed 12 years ago by guest

Bill, can I have your answer to my last post ( definitive fix working ).. Thank you.

comment:10 Changed 12 years ago by bill

Resolution: fixed
Status: newclosed

(In [9265]) Make getParent() only return a value if parent is a _Container. This prevents layout widgets from thinking they are being controlled by a parent layout widgets when really they are just floating free inside a ContentPane?.

Fixes #3448, #3406.

Note: See TracTickets for help on using tickets.