Back to blue

Disclosure

Implementation

Make sure to import the following helper JS:

import Disclosure from '@consumeraffairs/ca-styleguide/modules/ca_sg_disclosure/disclosure.es6';

The feature

The goal of this feature is to keep centralized the Disclosure Approach across the apps.

Usage

Since you included the file mentioned above, you just have to use the following snippet.


HTML

<div class="discl"> <div class="js-discl discl__txt"></div> </div>

JS

import Disclosure from './disclosure.es6'; new Disclosure();

Config Options

You could start the disclosure with a config object. Like that:

  • endpoint: request API destination
  • callback: function to be called on success
  • parser: function that the response will pass into that
  • method: method of API call
const options = { endpoint: `/`, callback: fn, parser: fn, method: 'GET' }; new Disclosure(options);

Default values are:

{ endpoint: '/api/disclosure/buyers-guide/', callback: () => {}, parser: (content) => content, method: 'GET', }

You could also specify only what you need example below, the rest will use default values:

const options = { endpoint: `/` }; new Disclosure(options);