Custom Widget Javascript

For additional customizations of behavior in the widget (such as removing some fields entirely, changing the order, etc.), you'll need to use Javascript (JS) in the widget.

If you make changes to these settings, they should show up nearly instantly in your live widget.

To add widget JS:

  1. Go to KB settings > Widget.
  2. Add your JS to the Custom Widget Javascript section.
  3. Save your changes.

No script tags needed
You don't need to add <script> tags around code entered in the Custom Widget Javascript section--we automatically wrap this box in script tags!

Working with the Contact tab

Javascript for the contact form needs to go inside the onTabChange function. Inside this function, you have access to data.oldTab and data.newTab to hook onto the tabChange events:

//JS for the contact form needs to go inside onTabChange function
var onTabChange = function(data) {
      //you have access to the data.oldTab and data.newTab to hook onto these events if it helps. Example:
      console.log("Tab changed from " + data.oldTab + " to " + data.newTab);      
      //do some code down here
}

For example, this code will hide the "Upload file attachment" option in the contact form:

//JS for the contact form needs to go inside onTabChange function
var onTabChange = function(data) {
      //simple example of hiding an option
      //hide file attachment option
      $('.form__upload').hide();
}