Ok, I figured it out. It has to do with the MODULE_ID renderParam, which is
why I didn’t see this issue until I implemented module_id stuff.
If I do the following:
var renderParams = {};
renderParams[osapi.container.RenderParam.MODULE_ID] = 1;
container.navigateGadget(gadgetSite, gadgetXml, {}, renderParams, function(){
// 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);
});
activeSiteHolder is undefined on the first getter (even though I’m in the
callback function). If I removed the 2nd line and not set the MODULE_ID render
param then it works. I’ll see if I can dig into why.
doug
On May 6, 2015, at 9:36 AM, Davies,Douglas
<[email protected]<mailto:[email protected]>> wrote:
Stanton,
I could have sworn that’s what my code was doing originally (the callback).
But I just tried it in the sample I sent and it’s working. Thanks! I’ll let
ya know if I experience any further problems with it.
doug
On May 5, 2015, at 8:35 PM, Stanton Sievers
<[email protected]<mailto:[email protected]>> wrote:
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 <[email protected]> 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 <[email protected]<mailto:
[email protected]>> 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 <[email protected]<mailto:
[email protected]>> 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