Opened 13 years ago

Closed 12 years ago

#2646 closed defect (wontfix)

addOnLoad is not recognizing contentpane html widgets in Firefox 2.0.0.3

Reported by: guest Owned by: anonymous
Priority: high Milestone:
Component: General Version: 0.4.2
Keywords: Cc:
Blocked By: Blocking:

Description

My Mac updated my Firefox from 2.0.0.2 to 2.0.0.3 automatically today. Suddenly my application stopped working. I created some test code to isolate the problem.

I have 2 html pages. One contains a contentpane that loads the second html page as content. The addOnLoad is not working when the second html page is loaded. The widget on my 2nd page shows as "undefined". dojo.addOnLoad does work if I load the 2nd page by itself in the browser instead of through the contentpane. Perhaps the problem is in dojo.addUnload or in contentpane.setUrl.

I tested the same code in IE7 and on Firefox 2.0.0.2 on my Windows machine and it works fine. I then upgraded my Windows machine to Firefox 2.0.0.3 and my widget is once again "undefined".

Clearly something has changed from FF 2.0.0.2 to 2.0.0.3. This has pretty much brought my development to a standstill since I work mostly with FF on the Mac and my code relies heavily on dojo.addOnLoad and loading content into contentpanes.

Here is some code to show the error:

FIRST PAGE

<html>
<head>

<title>test</title>
<script type="text/javascript">
        var djConfig = {
        isDebug: true
        };
       
</script>
     
<script type="text/javascript" src="js/dojo-0.4.1-ajax/dojo.js"></script>
<script language="JavaScript" type="text/javascript">
        dojo.require("dojo.widget.*");
</script>
<script>
function loadPage(){
var w2 = dojo.widget.byId("mycontentpane");
w2.setUrl("newpage.html");

}
</script>
</head>
  <body >
  <input type="button" onclick="loadPage();" value="Click Me"/>
    <div dojoType="ContentPane"
    layoutAlign="client"
    widgetId="mycontentpane"
    style="background-color: #f5ffbf; padding: 10px; margin: 5px;"
    executeScripts="true"
    scriptSeparation="false"
    loadingMessage="loading..."
    cacheContent="false"
    href=""
    >

    </div>

</body>
</html>

SECOND PAGE

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></meta>
    <title>2nd page</title>
<script type="text/javascript">
        var djConfig = {
        isDebug: true
        };
       
</script>
     
<script type="text/javascript" src="js/dojo-0.4.1-ajax/dojo.js"></script>
<script language="JavaScript" type="text/javascript">
        dojo.require("dojo.widget.*");
        dojo.require("dojo.widget.FilteringTable");        
</script>

<script>
dojo.addOnLoad(function(){
    var w=dojo.widget.byId("fromJSONData");
    alert(w);
});

</script>
  </head>
  <body>
        <table dojoType="filteringTable" id="fromJSONData" widgetId="fromJSONData"
                multiple="true" alternateRows="true" maxSortable="3"
                cellpadding="0" cellspacing="0" border="0" style="width:100%; margin-bottom:24px;" >
        <thead>
                <tr>
                        <th field="testDate" dataType="date" sort="desc" format="%d/%m/%Y">Test Date</th>
                        <th field="html" dataType="html" align="center">html</th>

                </tr>
        </thead>
  </table>
</body>
</html>

Change History (4)

comment:1 Changed 13 years ago by Adam Peller

My understanding of ContentPane? is limited, but it apparently deals in document fragments, so your second page, when loaded this way, isn't a page with a load event. addOnLoad therefore executes immediately rather than being tied to any page or parse events, so there's no guarantee that your widget will be in place. Such an event would have to be wired up to ContentPane?'s load event, I think? I'm not sure it's fair to expect the contents to function exactly as if it were a separate page, given that addOnload already has an implied state before you load up your content pane.

comment:2 Changed 13 years ago by dylan

Mozilla thinks is may be related to https://bugzilla.mozilla.org/show_bug.cgi?id=371576

comment:3 Changed 12 years ago by guest

I am experiencing the same issue in FireFox? 2.0.0.4. The Mozilla bug page didn't seem to come to a resolution. Is there a workaround for this issue? I tried adding onload handlers on the widgets themselves, within the html tags and the _container_ variable, with no success. Any insight here would be appreciated. Thanks.

comment:4 Changed 12 years ago by bill

Resolution: wontfix
Status: newclosed

Like Adam said above, having the dojo.addOnLoad() inside your second page is invalid; you need to use ContentPane?'s mechanism for triggering something to happen after the href finishes loading.

Note that in Dijit 0.9's ContentPane? we won't be supporting stuff like <script> tags in the second document either, but there will be an advanced version of ContentPane? in dojox that does.

Note: See TracTickets for help on using tickets.