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…

PropertyMeaning
controlA CSS selector of the input control
targetA DIV or other HTML element that will contain the autocomplete options
serverThe URL to the ARDI server
callbackThe name of the callback function to be called when a final asset is chosen
singleOptional - 'true' if the selector should only have a single result (rather than many)
propertiesOptional - 'false' if you only want assets to be selected rather than properties
terminalsOptional - 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 + '!');
};