Custom - AFS

AFS Integration Guide

Product
AFS
AFS_Version
7.9
Category
Reference Guide

This component can be used to make an advanced reply formatting that cannot be done using built-in components.

This component enables to build its DOM tree. It enables events, effects, interaction, ... managing. In fact, anything JavaScript enables to.

It requires knowledges in JavaScript language.

This component takes only one mandatory option:

<div class="AFSWidgetResultComponent" title="Custom">
<script type="application/json">
{ "resultCallback": "displayUri" }
</script>
</div>

It is necessary to implement a JavaScript function that takes two parameters:

  • The DOM element for which the DOM tree has to be built.
  • A JavaScript object where can be found the whole reply tree.

It is strongly recommended to use a JavaScript library to implement such functions. JQuery is a well-known JavaScript library that enables to manipulate DOM tree and parse XML streams easily.

It is used in the following example (jquery.js must be loaded in the page for this example to work):

<!-- Somewhere in your page -->
<script type="text/javascript">
function displayUri(element, result) {
// Embeds the element in a JQuery
var $element = $(element);
// Creates a paragraph node whose class is paragraph (the text attribute will be inserted inside the node)
var $paragraph = $('<p />', {class: "paragraph", text: 'Result URI is ' + reply.uri});
// Attaches the just created node to the element given by the widgets API
$element.append($paragraph);
}
</script>

Note that the function must be defined in the integration page.