Author Topic: LazyLoad Widgets  (Read 3068 times)

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7641
  • Karma: 56330
LazyLoad Widgets
« on: August 19, 2019, 07:17:02 PM »
Hi guys
I am trying to make a sample for the new Widgets and trying to understand this LazyLoad method.
I added and modified the script provided at the docs
[code]
<script src="widgets/cxbus.min.js" onload="javascript:CXBus.configure({debug:true,pluginsPath:'plugins/'});CXBus.loadFile('widgets.config.js').done(function(){CXBus.loadPlugin('widgets-core')});"></script>
[/code]


So at widgets.config.js I put the launcher.html output.
Also added the script
[code]

<script>

        if(!window._genesys)window._genesys = {};
        if(!window._gt)window._gt = [];

        window._genesys.widgets = {

                main: {},
                webchat: {}

        };

[/code]


Before everything else.
Yet, doesn't seems to work...any clue what I may be missing or how does this is supposed to work?


Offline jamesmurphyau

  • Full Member
  • ***
  • Posts: 123
  • Karma: 2
Re: LazyLoad Widgets
« Reply #1 on: August 20, 2019, 02:36:14 AM »
Where are your plugins located? Are the in /widgets/plugins or are they in /plugins?

If they are located at /widgets/plugins then you need to update your pluginsPath.

My folder structure looks like:

js/cxbus.min.ja
js/plugins/widgets-core.min.js
js/plugins/webchat.min.js

and in this case, I set the plugins path to js/plugins/

Are there any errors in the developer tools console on Google Chrome?

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7641
  • Karma: 56330
Re: LazyLoad Widgets
« Reply #2 on: August 20, 2019, 02:25:50 PM »
No erros, I see at console that everythings loads up correctly. What I think is missing how to call the webchat open API...is it supposed to be there or need to add some extra code?

Offline hsujdik

  • Hero Member
  • *****
  • Posts: 541
  • Karma: 30
Re: LazyLoad Widgets
« Reply #3 on: August 20, 2019, 02:44:12 PM »
Then, try this:

[code]
window._genesys.widgets.onReady = function(bus) {
    bus.command("Webchat.open");
}
[/code]

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7641
  • Karma: 56330
Re: LazyLoad Widgets
« Reply #4 on: August 20, 2019, 04:52:44 PM »
Yes! that made it! Thanks! Was using the doc one but was getting an error...thanks!