Set preload false not working when programmatically creating a content pane as a hidden child of a tab container

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Set preload false not working when programmatically creating a content pane as a hidden child of a tab container

Yiqin Yu
This post was updated on .
I have a dojo widget "Test" inheriting dijit.layout.contentpane, and set preload=false in its constructor:

dojo.declare("Test", [ dijit.layout.ContentPane ], {
        constructor: function(){
                this.preload = false;
                this.set("href", "/simple.do");
        }
});


Now I want to create an instance of "Test" as a hidden child of a tab container. When I create the instance declaratively, preload = false works well, inner content is not loaded until I click the hidden tab.

<div id="container" dojoType="dijit.layout.TabContainer" style="width:1000px;height:400px;">
        <div dojoType="dijit.layout.ContentPane" title ="22222" style="width: 200px;">2222</div>
        <div id="ttt" dojoType="Test" title="Space" >
                This is a customized content pane.
        </div>
</div>



But when I create the instance programmatically, preload = false does not work, inner content is loaded once the whole page be loaded.

dojo.ready(function(){
        test = new Test({
                title: "test widget"
        });
        test.startup();
        dijit.byId("container").addChild(test);
});


Do I make any wrong statement?

Reply | Threaded
Open this post in threaded view
|

Re: Set preload false not working when programmatically creating a content pane as a hidden child of a tab container

Aaasaasa
This post was updated on .
dojo.ready(function(){
        test = new Test({
                title: "test widget"
        });
        test.startup();
        dojo.byId("container").addChild(test); //dijit.byId("container").addChild(test);
});

PS.
hmm what I've written? :) I made ​​it on the side, sorry
thanks ben
Reply | Threaded
Open this post in threaded view
|

Re: Set preload false not working when programmatically creating a content pane as a hidden child of a tab container

neonstalwart
That's wrong. dijit.byId was right. It should work as desired to do the addChild and not call startup on the child - the parent will startup the child once the parent is started.

ben...



Sent from my Palm Pre on AT&T


On Jul 25, 2011 5:33, Aleksandar Stajic <[hidden email]> wrote:

dojo.ready(function(){
test = new Test({
title: "test widget"
});
test.startup();
*dojo*.byId("container").addChild(test);
//dijit.byId("container").addChild(test);
});

--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/Set-preload-false-not-working-when-programmatically-creating-a-content-pane-as-a-hidden-child-of-a-tr-tp3196970p3196984.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.
________________________________________________________
Dojotoolkit: http://dojotoolkit.org
Reference Guide: http://dojotoolkit.org/reference-guide
API Documentation: http://dojotoolkit.org/api
Tutorials: http://dojotoolkit.org/documentation

[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

________________________________________________________
Dojotoolkit: http://dojotoolkit.org
Reference Guide: http://dojotoolkit.org/reference-guide
API Documentation: http://dojotoolkit.org/api
Tutorials: http://dojotoolkit.org/documentation

[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Set preload false not working when programmatically creating a content pane as a hidden child of a tab container

Yiqin Yu
Amazing! I remove "test.startup()" and it works now.

Thanks very much~
Reply | Threaded
Open this post in threaded view
|

Re: Set preload false not working when programmatically creating a content pane as a hidden child of a tab container

Yiqin Yu
In reply to this post by neonstalwart
Hi, neo,

Another question following the above circumstance. Now I've successfully made the hidden tab preload=false when loading the page. For some reason, I would destroy all tabs under the tab container without select and show the hidden tab's content:

dijit.byId("container").destroyDescendants();

Then an error occurred: Error: xhr cancelled

By checking the thread http://dojo-toolkit.33424.n3.nabble.com/Re-XHR-Cancelled-Error-Message-td1720344.html#a1735960 , I think it is because I set href for the hidden tab in its constructor, but for its preload is false, the xhr request is not complete when it is destroyed.

For avoiding this error message, do I must call test.startup() before call dijit.byId("container").destroyDescendants()?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Set preload false not working when programmatically creating a content pane as a hidden child of a tab container

Bill Keese-2
I remember I had an issue when I wrote the ContentPane XHR related code.   Normally cancelling a Deferred signifies an error, but in the case of cancelling an XHR it's not really an error, it's just that the app is cancelling a network request.   In other words, sometimes that error message shows up but it's not a real error.

But as to your question, I'm not sure what's going on or what you should do.   It's unclear to me when you call destroyDescendants() whether
   a) there has been no XHR request
   b) there's an XHR in progress
   c) the XHR is already completed

Anyway, it would be interesting to see a test case so I could debug it.

On Tue, Jul 26, 2011 at 12:38 PM, Yiqin Yu <[hidden email]> wrote:
Hi, neo,

Another question following the above circumstance. Now I've successfully
made the hidden tab preload=false when loading the page. For some reason, I
would destroy all tabs under the tab container without select and show the
hidden tab's content:

dijit.byId("container").destroyDescendants();

Then an error occurred: Error: xhr cancelled

By checking the thread
http://dojo-toolkit.33424.n3.nabble.com/Re-XHR-Cancelled-Error-Message-td1720344.html#a1735960
, I think it is because I set href for the hidden tab in its constructor,
but for its preload is false, the xhr request is not complete when it is
destroyed.

For avoiding this error message, do I must call test.startup() before call
dijit.byId("container").destroyDescendants()?

Thanks.

--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/Set-preload-false-not-working-when-programmatically-creating-a-content-pane-as-a-hidden-child-of-a-tr-tp3196970p3199381.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.
________________________________________________________
Dojotoolkit: http://dojotoolkit.org
Reference Guide: http://dojotoolkit.org/reference-guide
API Documentation: http://dojotoolkit.org/api
Tutorials: http://dojotoolkit.org/documentation

[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


________________________________________________________
Dojotoolkit: http://dojotoolkit.org
Reference Guide: http://dojotoolkit.org/reference-guide
API Documentation: http://dojotoolkit.org/api
Tutorials: http://dojotoolkit.org/documentation

[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Set preload false not working when programmatically creating a content pane as a hidden child of a tab container

Yiqin Yu
Hi, bill,

I put the test html pages here. In "test0727.html", there's a tab container, which has a hidden tab called "Tab 2 of Round 1" with preload = false.

When the user clicks the button "Replace current tabs" without clicking the hidden tab firstly, all tabs in the tab container are destroyed and new tabs are then inserted.
Here the error occurred: Error: xhr cancelled.

test0727.html
test0727-2.html
Reply | Threaded
Open this post in threaded view
|

Re: Set preload false not working when programmatically creating a content pane as a hidden child of a tab container

Bill Keese-2
Ah I see.    Well, unfortunately, calling destroyDescendants() destroys the tabs in order, which means that it first destroys the visible tab (tab 0), which thus selects the hidden tab, making it visible, and firing off the XHR request.    But then destroyDescendants() immediately destroys the second tab.

If you file a ticket I can change destroyDescendants() to destroy the selected tab last.    But also you can work around the problem with some custom code like:

dojo.forEach(con.getChildren(), function(child){
if(!child.selected){
con.removeChild(child);
}
});
con.destroyDescendants(); // destroy the final visible tab

On Wed, Jul 27, 2011 at 12:30 PM, Yiqin Yu <[hidden email]> wrote:
Hi, bill,

I put the test html pages here. In "test0727.html", there's a tab container,
which has a hidden tab called "Tab 2 of Round 1" with preload = false.

When the user clicks the button "Replace current tabs" without clicking the
hidden tab firstly, all tabs in the tab container are destroyed and new tabs
are then inserted.
Here the error occurred: Error: xhr cancelled.

http://dojo-toolkit.33424.n3.nabble.com/file/n3202290/test0727.html
test0727.html
http://dojo-toolkit.33424.n3.nabble.com/file/n3202290/test0727-2.html
test0727-2.html

--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/Set-preload-false-not-working-when-programmatically-creating-a-content-pane-as-a-hidden-child-of-a-tr-tp3196970p3202290.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.
________________________________________________________
Dojotoolkit: http://dojotoolkit.org
Reference Guide: http://dojotoolkit.org/reference-guide
API Documentation: http://dojotoolkit.org/api
Tutorials: http://dojotoolkit.org/documentation

[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


________________________________________________________
Dojotoolkit: http://dojotoolkit.org
Reference Guide: http://dojotoolkit.org/reference-guide
API Documentation: http://dojotoolkit.org/api
Tutorials: http://dojotoolkit.org/documentation

[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Set preload false not working when programmatically creating a content pane as a hidden child of a tab container

Yiqin Yu
Hi, Bill,

Thanks for your code! It runs well in my test case.
I also create a ticket for this problem: http://bugs.dojotoolkit.org/ticket/13552
Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Set preload false not working when programmatically creating a content pane as a hidden child of a tab container

Nokiae5review
This post has NOT been accepted by the mailing list yet.
Yes, I think this is very helpful
Reply | Threaded
Open this post in threaded view
|

Re: Set preload false not working when programmatically creating a content pane as a hidden child of a tab container

Yiqin Yu
In reply to this post by Bill Keese-2
One place.

It would be better to use con.closeChild(child) instead of con.removeChild(child).

removeChild just removes the child widget instance from the tab container but does not destroy it.

If the child content pane contains other widgets with a specified id, and this content pane is attached to the tab container again when clicking the button, in certain user click sequence, there will be an error: Error parsing in _ContentSetter#Setter_Test_1_3 Error: Tried to register widget with id==content but that id is already registered.
It is because the widget in the child content pane is not destroyed by con.removeChild(child).

It can be tested in the following test case (modified from the previous one):
test0727.html
test0727-2.html
Reply | Threaded
Open this post in threaded view
|

Re: Set preload false not working when programmatically creating a content pane as a hidden child of a tab container

Bill Keese-2
Ah right, after the removeChild(child) you need to call child.destroyRecursive().

On Mon, Aug 1, 2011 at 3:33 PM, Yiqin Yu <[hidden email]> wrote:
One place.

It would be better to use con.closeChild(child) instead of
con.removeChild(child).

removeChild just removes the child widget instance from the tab container
but does not destroy it.

If the child content pane contains other widgets with a specified id, and
this content pane is attached to the tab container again when clicking the
button, in certain user click sequence, there will be an error: Error
parsing in _ContentSetter#Setter_Test_1_3 Error: Tried to register widget
with id==content but that id is already registered.
It is because the widget in the child content pane is not destroyed by
con.removeChild(child).

It can be tested in the following test case (modified from the previous
one):
http://dojo-toolkit.33424.n3.nabble.com/file/n3215176/test0727.html
test0727.html
http://dojo-toolkit.33424.n3.nabble.com/file/n3215176/test0727-2.html
test0727-2.html

--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/Set-preload-false-not-working-when-programmatically-creating-a-content-pane-as-a-hidden-child-of-a-tr-tp3196970p3215176.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.
________________________________________________________
Dojotoolkit: http://dojotoolkit.org
Reference Guide: http://dojotoolkit.org/reference-guide
API Documentation: http://dojotoolkit.org/api
Tutorials: http://dojotoolkit.org/documentation

[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


________________________________________________________
Dojotoolkit: http://dojotoolkit.org
Reference Guide: http://dojotoolkit.org/reference-guide
API Documentation: http://dojotoolkit.org/api
Tutorials: http://dojotoolkit.org/documentation

[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest