Saber Feedback Documentation

Javascript API

Saber’s Javascript API allows you to interact with and control Saber through the global window.Saber object.

To avoid errors, you should define any functions that make use of the Javascript API within the Saber’s on_ready event, as shown in the example code for each API method.


open

The open method opens the Saber feedback interface in exactly the same way as when the feedback button is clicked. If the feedback interface is already open nothing will happen. If you have specified an `on_open` event handler, this will be triggered. There are no arguments passed to the open method.

Example:

var saber_options = {
  api_key: "[YOUR API KEY HERE]",
  on_ready: function() {
    Saber.open();
  }
};

close

The close method closes the Saber feedback interface in exactly the same way as when the feedback interface is cancelled. If the feedback interface is not currently open nothing will happen. If you have specified an `on_close` event handler, this will be triggered. There are no arguments passed to the close method.

Example:

var saber_options = {
  api_key: "[YOUR API KEY HERE]",
  on_ready: function() {
    Saber.close();
  }
};

button

The button method returns the HTML element for the default feedback button. There are no arguments passed to the button method.

Example:

var saber_options = {
  api_key: "[YOUR API KEY HERE]",
  on_ready: function() {
    var button_element = Saber.button();
  }
};

set_options

The set_options method allows you to set runtime options after Saber has been loaded. The options should be passed as a hash object to the `set_options` method.

Example:

var saber_options = {
  api_key: "[YOUR API KEY HERE]",
  on_ready: function() {
    Saber.set_options({
      language: 'fr', // set the language to French
      require_email: true // make the email field mandatory
    });
  }
};

set_option

The set_option method is a convenience method that allows you to set a single run time option. `set_option` requires two arguments, the option name, and its new value.

Example:

var saber_options = {
  api_key: "[YOUR API KEY HERE]",
  on_ready: function() {
    Saber.set_option('languge', 'fr'); // set the language to French
  }
};