Add onclick to Header and V2 Element Button

Hi,

I’m trying to trigger a livechat whenever the user clicks on the livechat button.

Feature Request: Please add onlick to V2 element buttons & header as well. It’s very difficult for us to maintain the styling when we manually add it. Thanks.

Regards

Hey @nebworx,

Thanks for your feedback. I’ll post this as feature request. For now, you can assign a class to your button to be used for your script like this https://www.w3schools.com/jquery/event_on.asp

Hi Christian,

Thanks for this, I know how to assign a class to a button, but how do I associate the script to the class? Thanks.

Similar to the link I referred, you can do it like this:

jQuery(".my-class").on("click", function(){
    alert("The button was clicked.");
});

Christian,

Thanks, so in this case I should write this in the Javascript section of the header:

jQuery(".trigger-chat").on("click", convertfox.chat('openNewConversation'){
alert("The button was clicked.");

});

and call “trigger-chat” as the class?

Thanks

It should be:

jQuery(".trigger-chat").on("click", function() {
  convertfox.chat('openNewConversation');
});

Also note that it’s important to leave the URL of the button empty so the page won’t scroll to top when clicked.

Alternatively, you use preventDefault in the script. This touches more on coding though so you’ll need to be familiar with Javascript to use that.

Hope that helps.

Brilliant, it works, thanks very much!

Glad it’s works, and you’re most welcome!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.