Skip to content

Persisting data

In some cases it can be very useful to capture data in one slide and reuse it in another.

This can be achieved by using local storage and session storage feature of HTML5.

For example, a question may be asked of the Health Care Professional regarding the type of patients they are treating on the first slide and their response used to tailor the information they are presented with on the next slide.

Simply store a key and value in the local storage object in the first slide:

$slide.on('click', '#paediatricBtn', (e) => {
    //store the patient type in local storage
    localStorage.setItem('patientType','paediatric');
});

then reference this key in the next slide:

$slide.on('slideLoaded', (e) => {
    //retrieve the patient type from local storage
    var patientType = localStorage.getItem('patientType');
});

This can also be done from within HTML Packages to build more dynamic experiences.

Text area Interpolation

You can easily use values in both the local and session storage inside Text Content Areas in the Slide Editor via templating tags.

Example

The following text would replace {{ls.patientType}} with the value of patientType from the localStorage

For all {{ss.patientType}} patients

would become

For all paediatric patients

See Templating / Interpolation for more information.