A similar issue is discussed in the mail thread [1] at dev@ The reason seems to be the pub-sub model doesn't wait till the iframe is loaded. In the above thread it is suggested to register an onload event for gadget iframes. Have you tried that? @ Kavith : Were you able to find a solution? Did iframe onload event solved your issue?
[1] [Dev] WSO2 UES - How to forward request parameters to micro-sites (gadgets) Thanks, Tanya On Wed, Mar 9, 2016 at 9:34 AM, Udara Rathnayake <[email protected]> wrote: > > > On Tue, Mar 8, 2016 at 7:33 PM, Dilan Udara Ariyaratne <[email protected]> > wrote: > >> Hi Damith, >> >> How about using the jquery ready() function, so that you can make sure >> the function runs >> just after DOM (document object model) has been fully loaded? >> >> For ex: see the following code snippet. >> >> var TOPIC = "publisher"; >> var count = 1; >> >> function cb(start, end) { >> if (count != 0) { >> var message = { >> timeFrom: new Date(start).getTime(), >> timeTo: new Date(end).getTime() >> }; >> console.log(message); >> gadgets.Hub.publish(TOPIC, message); >> } >> count++; >> } >> >> >> >> >> $(document).ready(function () { >> cb(moment().subtract(29, 'days'), moment()); >> }); >> > *$(function() { })* this is the shorthand version of > > > *$(document).ready*, So I don't see any difference here. > >> >> >> Cheers, >> Dilan. >> >> >> >> *Dilan U. Ariyaratne* >> Software Engineer >> WSO2 Inc. <http://wso2.com/> >> Mobile: +94725197942 >> lean . enterprise . middleware >> >> On Tue, Mar 8, 2016 at 10:03 PM, Damith Wickramasinghe <[email protected]> >> wrote: >> >>> HI Udara, >>> >>> Thanks for the response. Set time out works but is it a good approach >>> since the time can be vary. >>> >>> Regards, >>> Damith. >>> >>> On Tue, Mar 8, 2016 at 8:12 PM, Udara Rathnayake <[email protected]> >>> wrote: >>> >>>> cay you try, >>>> >>>> setTimeout(function (){ >>>> cb(moment().subtract(29, 'days'), moment()); >>>> }, 3000); >>>> >>>> >>>> On Tue, Mar 8, 2016 at 9:32 AM, Damith Wickramasinghe <[email protected] >>>> > wrote: >>>> >>>>> Hi, >>>>> >>>>> I have a requirement of publishing data on load of publisher gadget. >>>>> I have following script >>>>> >>>>> $(function () { >>>>> >>>>> var TOPIC = "publisher"; >>>>> >>>>> var count = 1; >>>>> >>>>> cb(moment().subtract(29, 'days'), moment()); >>>>> >>>>> function cb(start, end) { >>>>> if (count != 0) { >>>>> var message = { >>>>> timeFrom: new Date(start).getTime(), >>>>> timeTo: new Date(end).getTime() >>>>> }; >>>>> console.log(message); >>>>> gadgets.Hub.publish(TOPIC, message); >>>>> } >>>>> count++; >>>>> } >>>>> >>>>> }); >>>>> >>>>> >>>>> As you can see I'm calling cb(moment().subtract(29, 'days'), >>>>> moment()); which will publish that data. If I comment above line and call >>>>> the function when a button click then publisher works. It seems publisher >>>>> functionality is not available or gadget is not properly loaded if we call >>>>> as above. Am I missing something here ? or is there a better way to >>>>> achieve >>>>> this ? >>>>> >>>>> Thanks, >>>>> Damith. >>>>> >>>>> >>>>> -- >>>>> Software Engineer >>>>> WSO2 Inc.; http://wso2.com >>>>> <http://www.google.com/url?q=http%3A%2F%2Fwso2.com&sa=D&sntz=1&usg=AFQjCNEZvyc0uMD1HhBaEGCBxs6e9fBObg> >>>>> lean.enterprise.middleware >>>>> >>>>> mobile: *+94728671315 <%2B94728671315>* >>>>> >>>>> >>>>> _______________________________________________ >>>>> Dev mailing list >>>>> [email protected] >>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>>>> >>>>> >>>> >>>> >>>> -- >>>> Regards, >>>> UdaraR >>>> >>> >>> >>> >>> -- >>> Software Engineer >>> WSO2 Inc.; http://wso2.com >>> <http://www.google.com/url?q=http%3A%2F%2Fwso2.com&sa=D&sntz=1&usg=AFQjCNEZvyc0uMD1HhBaEGCBxs6e9fBObg> >>> lean.enterprise.middleware >>> >>> mobile: *+94728671315 <%2B94728671315>* >>> >>> >>> _______________________________________________ >>> Dev mailing list >>> [email protected] >>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>> >>> >> > > > -- > Regards, > UdaraR > > _______________________________________________ > Dev mailing list > [email protected] > http://wso2.org/cgi-bin/mailman/listinfo/dev > > -- Tanya Madurapperuma Senior Software Engineer, WSO2 Inc. : wso2.com Mobile : +94718184439 Blog : http://tanyamadurapperuma.blogspot.com
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
