Selector.js
Selector.js is a Javascript library that helps you add ARDI selector auto-complete to any HTML edit field.
Including In Your Page
Adding these lines to the HEAD section of your page will import the library.
<script src="selector.js"></script> <link rel="stylesheet" href="ARDISERVER/selector/selector.css">
Enabling Autocomplete
<script> pageselector = new ARDISelector({ control: '#sidebarsearch', target: '#sidebarsearchac', server: 'MYSERVER', callback: "CALLBACKFUNCTION", single: true, properties: false }); </script>
The ARDISelector class needs a few parameters to enable auto-complete. These include…
Property | Meaning |
---|---|
control | A CSS selector of the input control |
target | A DIV or other HTML element that will contain the autocomplete options |
server | The URL to the ARDI server |
callback | The name of the callback function to be called when a final asset is chosen |
single | Optional - 'true' if the selector should only have a single result (rather than many) |
properties | Optional - 'false' if you only want assets to be selected rather than properties |
terminals | Optional - A list of options that should be offered to the user for an asset |
Capturing Selections
When the user has reached a 'terminal point' (a point where the selector is finished), the system calls the specified callback function, passing the chosen selector as a parameter.
For instance, if the callback parameter to your ARDISelector call was 'SelectorDone', you'd be able to define a function like the one below…
function SelectorDone(sel) { alert('The User Selected ' + sel + '!'); };