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
Methods
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?