Hi Doug,

If you want to get a handle to the sites and holders you should be doing so
in the optional callback to navigateGadget.  See the method signature [1]
for more information.  You can also hook the lifecycle callbacks [2] and
listen for ON_NAVIGATED [3] and you'll be given the site after the gadget
has rendered.

I hope that helps!

-Stanton

[1]
https://github.com/apache/shindig/blob/trunk/features/src/main/javascript/features/container/container.js#L192
[2]
https://github.com/apache/shindig/blob/trunk/features/src/main/javascript/features/container/container.js#L275
[3]
https://github.com/apache/shindig/blob/trunk/features/src/main/javascript/features/container.util/constant.js#L170

On Tue, May 5, 2015 at 9:29 AM, Davies,Douglas <davi...@oclc.org> wrote:

> Hi Stanton,
>
> Thanks for the feedback.
>
> Here’s a working (or non-working) example of the problem.  Just drop this
> in your common container directory along-side index.html.
>
> <html><body onload="init();"><div id="1"></div></body></html>
>
> <script type="text/javascript"
> src="../../../gadgets/js/container.js?c=1&debug=1&container=default"></script>
> <script type="text/javascript">
>     function init() {
>         var gadgetXml = '
> https://dl.dropboxusercontent.com/u/445894/gadgets/settitle.xml';
>         var container = new osapi.container.Container({});
>         var gadgetSite = container.newGadgetSite(
> document.getElementById('1') );
>         container.navigateGadget(gadgetSite, gadgetXml, [], {});
>         // log active site immediately (undefined)
>         console.log("activeSiteHolder1=" +
> gadgetSite.getActiveSiteHolder());
>         // log active site 1 second later (now has a value)
>         setTimeout(function() {
>             console.log("activeSiteHolder2=" +
> gadgetSite.getActiveSiteHolder());
>         }, 1000);
>     }
> </script>
>
> and the output
>
> "activeSiteHolder1=undefined"
> "activeSiteHolder2=[object Object]"
>
> Occasionally even activeSiteHolder2 will still be undefined.  A refresh
> usually causes it to have a value.  activeSiteHolder1 always appears to be
> undefined.  This occasionally bites us with our chrome not rendering
> (chrome not shown here) because it’s dependent on finding the gadget
> element.
>
> Should I reopen or create a new jira?  I can try to look into why it’s
> doing this.  Any suggestions are welcome.  I tried to wait for the onRender
> lifecycle callback, and even that didn’t work.
>
> Also (Ryan included), about my earlier question about updating the wiki
> with my module_id discoveries… how is that commonly done.  Funneled through
> someone?
>
> Thanks,
> doug
>
> On May 1, 2015, at 9:28 AM, Stanton Sievers <ssiev...@apache.org<mailto:
> ssiev...@apache.org>> wrote:
>
> This seems vaguely familiar but I can't pinpoint a JIRA ticket for the
> exact issue.  I did find [1] which I encountered a year ago or so.
>
> What version of Shindig are you using?  At what point in the gadget
> lifecycle are you trying to get the active holder?
>
> [1] https://issues.apache.org/jira/browse/SHINDIG-1965
>
> On Wed, Apr 29, 2015 at 11:39 AM, Davies,Douglas <davi...@oclc.org<mailto:
> davi...@oclc.org>> wrote:
>
> Has anyone had any inconsistencies with gadgetSite.getActiveSiteHolder()
> not being initialized immediately after container.navigateGadget?  I use
> this to add chrome to my gadget.  Sometimes this fails because the active
> site holder isn’t set yet.  If I delay for a second (or add an alert) then
> it’s set.  I even tried adding an onRender lifecycle callback, with the
> same result (I figured if I was getting the callback rendering should be
> done).  It appears that it’s either suppose to return loadingGadgetHolder
> or currentGadgetHolder.
>
> Ideas?
>
> doug
>
>
>
>
>

Reply via email to