Methods

A Relapse instance also expose some basic methods for programmatic control.

import relapse from 'relapse';

const method = relapse('.selector');

method.config({})          // Update and resets the options
method.expand(0);           // Expands fold at index 0
method.expand('foo');       // Expands fold with id value of "foo"
method.collapse(1);         // Collapse fold at index 1
method.collapse('bar');     // Collapse fold with id value of "bar"
method.destroy();           // Destroy the relapse instance
method.reinit();            // Destroy and reinitialize instance

Example

Click the buttons to open and close folds. This example is using the expand() and collapse() methods as we have demonstrated above. Below you can adjust some options for this instance.

Foo

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Elementum sagittis vitae et leo duis ut. Ut tortor pretium viverra suspendisse potenti.

Bar

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Tincidunt nunc pulvinar sapien et ligula ullamcorper malesuada proin. Ac tortor dignissim convallis aenean et tortor at risus.

Baz

Commodo sed egestas egestas fringilla phasellus faucibus. Eu tincidunt tortor aliquam nulla facilisi cras fermentum. Nullam eget felis eget nunc lobortis mattis. Et netus et malesuada fames ac turpis egestas maecenas. Vitae turpis massa sed elementum tempus egestas.


Updating Options

Below we are taking advantage of the options() method which will update the configuration settings of a specific Relapse instance. The example has omitted some option settings for the sake of the example.

It’s important to note that options such as schema, unique and classes are not available in post-instance states. This means you cannot augment these settings via the options() method.