For the complete documentation index, see llms.txt. This page is also available as Markdown.

Compare

Render product comparisons and highlight differences.

Documentation

Overview

Use ff-compare to display records with additional information and styling for fields that differ. Nest an ff-record-list to render and style compared products. This record list does not listen to default search results. It receives records from the compare service.

<ff-compare>
    <ff-record-list>
        <ff-record>
            <!-- Implement record presentation here. -->
        </ff-record>
    </ff-record-list>
</ff-compare>

Demo

Try the Compare demo.

API code

Properties

Properties
Name
Description

record-id (Array)

The record IDs of the products to compare.

max-results (Number) (default: 4)

The maximum amount of dispatched records.

subscribe (String) Options: "true", "false" (default: "true")

If set to "false", the element no longer listens to events and therefore does not receive new data. This is useful if you want to dispatch your own data to the element.

auto-compare (String) Options: "true", "false" (default: "false")

If set to "true", the request to the compare service will be automatically triggered when the attribute record-id is changed.

Methods

Methods
Name
Description

compareRecords(recordIds)

This method triggers a request to the Compare Service with the given recordIds.

Attributes

max-results

max-results defines how many records the component dispatches to ff-record-list. It defaults to 4.

record-id

Set a comma-separated list of record IDs with record-id to trigger the compare service. Set IDs through JavaScript after a user selects records.

subscribe

Use subscribe to control whether ff-compare listens to the compare service. It defaults to true.

auto-compare

auto-compare controls whether the compare service runs automatically after record IDs change. It defaults to true. Set it to false and call compareRecords() for manual control.

Styling

Comparing attributes

Add data-attribute="fieldName" to an element inside the record list. After comparison, differing fields receive ffw-compare-diff. Matching fields receive ffw-compare-equal. If the service has no result for a field, all ffw-compare-* classes are removed.

Mustache rendering

The compare result adds a diff property to each dispatched record. Use Mustache sections to render different markup:

Last updated

Was this helpful?