Skip to content

Methods & Properties

When contentfry display SDK is loaded, it initialize global instance in $cf variable with helpful methods and properties:

Displays have custom settings and SDK manages action handling differently.
For example clicking a link might open a modal instead of opening link in new window.
That is why please avoid using static links and add click event to all possible elements.

Methods

$cf.ui variable provides following public methods.

All event parameters are optional.

If event is provided, SDK prevents default event bubbling, helps preventing link opening.

click

Let SDK know about user clicks on a property in the display.

Display calls $cf.ui.click with clicked broadcast and property path in the broadcast: for example: 'link', 'connection.link'

  • Broadcast: Object
  • Path: String
  • Event: Object (Optional)
js
$cf.ui.click(broadcast, 'link', event)

sharesites

Array of sites to share

js
$cf.ui.sharesites();
// ['facebook', 'twitter']

share

Similar to click method, share method is used when users click to share a link on social media.

  • Broadcast: Object
  • Share site: String
  • Event: Object (Optional)
js
$cf.ui.share(broadcast, 'facebook', event)

loadmore

If display supports loading more contents, when user clicks load more button, loadmore action should be called.

js
$cf.ui.loadmore((response) => {
  // New broadcasts in response and if can load more.
  // Response: { broadcasts : response.broadcasts, can_loadmore : response.can_loadmore }
});