Closed meelie closed 4 years ago
Same bug today with new client GL events Thomas bug : What the debug say => document.body null because body is not loaded
<head>
Replace in yelda and webchat plugin
yeldaChat.setupChat({
'assistantSlug':assistantSlug,
'assistantId':assistantId,
'assistantUrl':assistantUrl, // url https://app.yelda.ai
'locale': 'fr_FR'}),
'chatPath': '/chat',
'isAdmin': true, // isAdmin boolean activate admin mode, default value is false
'shouldBeOpened': true, // boolean open the chat window by default on loading the page if set to true
'parentContainerId' : `chat_frame`, // (dom element id), if the 'container_id' does not exists in the dom, the iframe will be inserted into document body
'isStartBtn': false, // set to true only if need to show start button
'canBeClosed': false // used to toggle the visible state of close button, if parentContainerId provided 'canBeClosed' set to false
Note : you can replace _setupChat_ function by _init_ if you want to wait for window.onload event.
By
yeldaChat.init({
assistantSlug: assistantSlug,
assistantId: assistantId,
assistantUrl: assistantUrl, // url https://app.yelda.ai
locale: 'fr_FR',
chatPath: '/chat',
isAdmin: true, // isAdmin boolean activate admin mode, default value is false
'shouldBeOpened': true, // boolean open the chat window by default on loading the page if set to true
'parentContainerId' : `chat_frame`, // (dom element id), if the 'container_id' does not exists in the dom, the iframe will be inserted into document body
'isStartBtn': false, // set to true only if need to show start button
'canBeClosed': false // used to toggle the visible state of close button, if parentContainerId provided 'canBeClosed' set to false
})
To avoid issue with window.onload which might not be called when using JS Frameworks, you can also use `yeldaChat.setupChat(data)`, and even reset it with `yeldaChat.reset(data)`
Context Thomas tried to add yelda webchat on SG wordpress and faced this issue. Uncaught TypeError: Cannot read property 'appendChild' of null
Facts I quickly checked the code and noticed that
it works
=> DOM was not ready
My suggestion
Thanks