Forum Moderators: open
I want the suggestion to be done if the first letter of first name or
last name is typed. How can I get this done? Is there a particular
option to set? Version of the YUI I am using is 2.5.2. Below is the
code I am using in my template.
employee - is an array containing full names of employees (each full
name only contains first name and last name. No middle names.)
txtEmployeeSearch - is the name of the text box
employeeSearchACCon tainer - is the div where suggestion gets populated.
<script type="text/javascri pt">
YAHOO.OrangeHRM. autocomplete. ACJSArray = new function() {
// Instantiate first JS Array DataSource
this.oACDS = new YAHOO.widget. DS_JSArray( employees) ;
// Instantiate AutoComplete for txtEmployeeSearch
this.oAutoComp = new
YAHOO.widget. AutoComplete( 'txtEmployeeSear ch','employeeSea rchACContainer' ,
this.oACDS);
this.oAutoComp. prehighlightClas sName = "yui-ac-prehighligh t";
this.oAutoComp. typeAhead = false;
this.oAutoComp. useShadow = true;
this.oAutoComp. minQueryLength = 1;
this.oAutoComp. textboxFocusEven t.subscribe( function( ){
var sInputValue = YAHOO.util.Dom. get('txtEmployee Search'). value;
if(sInputValue. length === 0) {
var oSelf = this;
setTimeout(function (){oSelf. sendQuery( sInputValue) ;},0);
}
});
};
</script>