webaura Posted February 10, 2016 Share Posted February 10, 2016 Some help with this one would be greatly appreciated. I am trying to figure out how to use the onclick option for my Live Chat link. I have the following code in my hook: <?php #adding Live Chat Menu Item to secondaryNavbar use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondaryNavbar', 1, function (MenuItem $secondaryNavbar) { $secondaryNavbar->addChild('Live Chat') ->setUri('#chat onclick="toggleChat()"') ->setOrder(10); }); I have tried other ways, but can't seem to get the onclick to set. My goal is to have the live chat pop up on click. 0 Quote Link to comment Share on other sites More sharing options...
webaura Posted February 10, 2016 Author Share Posted February 10, 2016 I have this code in header.tpl of my theme: <script type="text/javascript"> function toggleChat() { Tawk_API.toggle(); return false; } </script> And this code before secondary-nav is called: <script type="text/javascript">Tawk_API.onStatusChange = function (status){if(status === 'online'){document.getElementById('status').innerHTML = '<a href="#" onclick="toggleChat()">Online - Click to chat</a>';}else if(status === 'away'){document.getElementById('status').innerHTML = 'We are currently away';}else if(status === 'offline'){document.getElementById('status').innerHTML = 'Live chat is Offline';}}; </script> 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.