inputEx - MultiAutoComplete Usage

Basic MultiAutoComplete creation

Use the following code to create a basic inputEx MultiAutoComplete. (note: this example doesn't work offline)

1var field = new inputEx.MultiAutoComplete({ 
2    parentEl: 'container1',  
3    label: 'Search US state'
4 
5    // see http://developer.yahoo.com/yui/examples/autocomplete/assets/js/states_jsfunction.js for getState function 
6    datasource: new YAHOO.widget.DS_JSFunction( getStates), 
7 
8    // Format the hidden value (value returned by the form) 
9    returnValue: function(oResultItem) { 
10        return oResultItem[1]; 
11    }, 
12 
13    returnLabel: function(oResultItem) { 
14        return oResultItem[0]; 
15    }, 
16 
17    // autocompleter options 
18    autoComp: { 
19        forceSelection: true
20        minQueryLength: 2, 
21        maxResultsDisplayed: 50, 
22        formatResult: function(oResultItem, sQuery) { 
23           var sMarkup = oResultItem[0] + " (" + oResultItem[1] + ")"
24           return sMarkup; 
25       } 
26    } 
27}); 
28 
29var logDiv = inputEx.cn('div'nullnull""); 
30YAHOO.util.Dom.get('container1').appendChild(logDiv); 
31 
32field.updatedEvt.subscribe(function(e,params) { 
33    var value = YAHOO.lang.JSON.stringify(params[0]); 
34    logDiv.appendChild( inputEx.cn('div',null,null,"Updated at "+(new Date())+" "+value) ); 
35}); 
view plain | print | ?