BugMuncher Documentation

Javascript API

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

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


open

The open method opens the BugMuncher 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 bugmuncher_options = {
  api_key: "[YOUR API KEY HERE]",
  on_ready: function() {
    bugmuncher.open();
  }
};

close

The close method closes the BugMuncher 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 bugmuncher_options = {
  api_key: "[YOUR API KEY HERE]",
  on_ready: function() {
    bugmuncher.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 bugmuncher_options = {
  api_key: "[YOUR API KEY HERE]",
  on_ready: function() {
    var button_element = bugmuncher.button();
  }
};

set_options

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

Example:

var bugmuncher_options = {
  api_key: "[YOUR API KEY HERE]",
  on_ready: function() {
    bugmuncher.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 to arguments, the option name, and its new value.

Example:

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